-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: parts of #29667 #29677
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
CLN: parts of #29667 #29677
Conversation
@@ -197,7 +197,9 @@ class Op: | |||
Hold an operator of arbitrary arity. | |||
""" | |||
|
|||
def __init__(self, op, operands, *args, **kwargs): | |||
op: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, there is a op
attribute that is a str
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary?
reveal_type(_bool_op_map)
reveal_type(_bool_op_map.get("not", "not"))
pandas\core\computation\ops.py:193: note: Revealed type is 'builtins.dict[builtins.str*, builtins.str*]'
pandas\core\computation\ops.py:194: note: Revealed type is 'builtins.str'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it necessary?
i guess im not clear on the policy. i thought it was a "more is better" kind of thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just suspicious when I see unnecessary variable annotations since they could be casts in disguise.
In this case, it could have been (but wasn't) hiding that the return type of _bool_op_map.get(op,op) might be Any.
If the return type of some_function is Any and we do some variable: some_type = some_function()
it is effectively a cast.
def some_function():
return "foo"
x: int = some_function()
reveal_type(x)
test.py:5: note: Revealed type is 'builtins.int'
I think we should just allow mypy to use the return type of the initialization unless needed.
from pandas.core.computation.common import _ensure_decoded | ||
from pandas.core.computation.expr import BaseExprVisitor | ||
from pandas.core.computation.ops import UndefinedVariableError, is_term | ||
|
||
from pandas.io.formats.printing import pprint_thing, pprint_thing_encoded | ||
|
||
|
||
class Scope(expr.Scope): | ||
class Scope(_scope.Scope): | ||
__slots__ = ("queryables",) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the medium-term goal that motivates this and the other pytables PR is that I think we can type queryables
as Dict[str, Any]
, but it'll take a few steps to get there
thanks |
Breaks off easier parts