Description
Summary
I noticed that I can't import, for example NonNegativeReals or Binary, without the type checker giving me the squiggly red line of badness. I dug into it and found that these are dynamically loaded into globals and they're never actually declared.
Lines 4548 to 4555 in cd778c5
Rationale
type checkers can't deal with dynamically assigned objects.
Description
I'm not sure if it's necessary to make each of them its own class or if it'd be enough to just have them declared as constants in set_types.py. Something like
from pyomo.core.base.range import NumericRange
from pyomo.core.base.set import RangeSet
from typing import cast
NonNegativeReals= cast(RangeSet,RangeSet(
name='NonNegativeReals',
doc='A global Pyomo Set admitting any real value in [0, +inf]',
ranges=(NumericRange(0, None, 0),),
)
)
without that explicit cast it wants to be RangeSet | AbstractFiniteScalarRangeSet | AbstractInfiniteScalarRangeSet
Ideally RangeSet
would have overloads so that it only returns one thing but maybe that can be the next typing improvement.
Additional information
The above could even be wrapped in an if typing
block since I don't really understand the implications of the docstring to DeclareGlobalSet