Skip to content

typing with args of global functions (except multiplication, element)#910

Open
tias wants to merge 2 commits intomasterfrom
mypy_globfunc
Open

typing with args of global functions (except multiplication, element)#910
tias wants to merge 2 commits intomasterfrom
mypy_globfunc

Conversation

@tias
Copy link
Copy Markdown
Collaborator

@tias tias commented Apr 7, 2026

skipped multiplication because of a float test that needs to be rewritten first

element because I expect some hard-to-type multidim related things that might be revised in #444 anyway

@tias tias requested a review from IgnaceBleukx April 7, 2026 11:15
Copy link
Copy Markdown
Collaborator

@IgnaceBleukx IgnaceBleukx left a comment

Choose a reason for hiding this comment

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

Yes, the xxx_listlike helper functions make a lot of sense!
I suppose we'll update the .value() funcs of Operator and GlobalConstraints in future PRs in a similar style?

One blocking comment on the addition in __pow__, otherwise looks good to go

raise TypeError("Power operator: modulo not supported")
if not isinstance(other, (int, np.integer)):
raise TypeError(f"Power operator requires a constant integer exponent, not: {other}")
if other == 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We will remove user vars with this enabled

return -arg, []

_abs = intvar(*self.get_bounds())
_abs = intvar(*self.get_bounds()) # not just lb,ub, see implementation
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

"Not just lb,ub of arg"?

r = intvar(*get_bounds(x % y)) # remainder
_div = intvar(*self.get_bounds())
return _div, safen + [(x == (y * _div) + r), abs(r) < abs(y), abs(y) * abs(_div) <= abs(x)]
defining.append(Comparison("==", x, (y * _div) + r))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just checking: this explicit Comparsion consruct is becase __eq__ is not typed, right?

@tias tias mentioned this pull request Apr 7, 2026
12 tasks
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