Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints or declarations for dynamically created RangeSet sets #2821

Open
alexchandel opened this issue May 3, 2023 · 0 comments
Open

Comments

@alexchandel
Copy link

Summary

Pyomo declares certain globals in a nontraditional manner, e.g. pyomo.core.base.set.NonNegativeReals. Pylance/Pyright reports a false positive "unknown import symbol" when you try to import them.

To Reproduce

from pyomo.environ import Binary, NonNegativeReals

These two symbols are defined here but Pylance does not recognize this, as "It's manipulating module namespaces in a way that's too dynamic for a static type checker to understand."

Static declarations or hints could be added under an if TYPE_CHECKING conditional, so they are never executed.

Rationale

Type checking catches lots of bugs. It should be encouraged and supported.

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

No branches or pull requests

1 participant