Uh oh!
There was an error while loading. Please reload this page.
Teach stubgen to work with complex and unary expressions - #15661
Conversation
AlexWaygood
commented
Jul 13, 2023
The PR title says stubtest -- you mean stubgen, right? |
stubtest to work with complex and unary expressionsstubgen to work with complex and unary expressionssobolevn
commented
Jul 13, 2023
|
| def get_str_type_of_node( | ||
| self, rvalue: Expression, can_infer_optional: bool = False, can_be_any: bool = True | ||
| ) -> str: | ||
| rvalue = self.unwrap_unary_expr(rvalue) |
There was a problem hiding this comment.
I'm not sure we should be doing this with all possible rvalues. Some unary expressions change the type:
>>> type(-True)
<class 'int'>There was a problem hiding this comment.
I guess it's pretty unlikely that this would ever come up in real code, but it would still be nice to be correct here imo :)
There was a problem hiding this comment.
Hm, ~True is also a well-known anti-pattern. I agree, I will include only some cases. Like not bool and +|- int|float|complex
Now I only allow a very small subset of unary expressions. But, ones I allow make a lot of sense and are very common. |
Uh oh!
There was an error while loading. Please reload this page.
No description provided.