Skip to content

Conversation

jonathanberthias
Copy link
Contributor

Hi @Joao-Dionisio! This is the first PR to set some things up. It's 99% autogenerated stubs using stubgen(part of the Mypy project), and then I just fixed a couple easy things.

This should be enough for LSPs/type checkers to know what exists in the PySCIPOpt package, but the types themselves are currently useless since nearly all methods take *args, **kwargs.

I separated everything I did into small commits so you can see what I did exactly. The first commit is the raw output from stubgen, the others fix some things here and there but nothing important.

One note on the organization: the stubs should mirror the structure of the final package. In this case, it means almost everything is in scip.pyi.


I didn't include docstrings. I do have a script in my repo that parses the source Cython files with regexes and adds the docstrings to the stubs, but I recently found out about astral-sh/docstring-adder and I would like to see if that can be applied to this project. If so, it is a much more trustworthy approach since it relies on runtime objects and not on fragile manual parsing.
In any case, I'll tackle that in another PR 😄

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces type stubs for the PySCIPOpt package to improve type checking and IDE support. The stubs were generated using stubgen from the Mypy project and then manually refined to fix issues and add type annotations to function parameters.

  • Type stubs provide LSP/type checker awareness of PySCIPOpt package structure
  • Parameter type annotations added to recipe functions for better type safety
  • Import statements updated to use explicit re-exports with type annotations

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/pyscipopt/scip.pyi Main type stub file containing all class and function signatures with placeholder types
src/pyscipopt/recipes/nonlinear.py Added type annotation to sense parameter
src/pyscipopt/recipes/infeasibilities.py Added type annotation to verbose parameter
src/pyscipopt/_version.py Added type annotation to __version__ variable
src/pyscipopt/init.py Updated imports to use explicit re-export syntax for better type checking

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@Joao-Dionisio Joao-Dionisio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tried it out, and it's indeed quite useful @jonathanberthias thank you!
Feel free to open the next one, whenever you're ready :)

@Joao-Dionisio Joao-Dionisio merged commit 04af6e8 into scipopt:master Oct 6, 2025
1 check passed
@Joao-Dionisio
Copy link
Member

Forgot to request a changelog entry, we can do it in the next one 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants