TypeVar with constraints causes conflicting type checker errors - redundant cast vs incompatible assignment #2018
Replies: 1 comment
-
please tell me this is not the solution@staticmethod
def testAttribute(
action: Callable[[TypeVar_ast_expr_bound_covariant], TypeVar_ast_expr_bound_covariant]
# action: Callable[[ast.expr], ast.expr]
) -> Callable[[hasDOTtest], hasDOTtest]:
def workhorse(node: hasDOTtest) -> hasDOTtest:
setattr(node, 'test', action(getattr(node, 'test')))
return node
return workhorse I hate |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The type checkers are wrong, but I don't really care. I just want any (manageable) syntactic system in which the type checkers will get the typing right.
If the type checkers will work, I'm willing to learn other systems, like protocol or I-don't-know-what.
Mypy states it most clearly: when Mypy looks at the right-hand side,
node.annotation
d'RHS is typefooT
, therefore I'm an idiot becausecast
is redundant; and when Mypy looks at the left-hand side,node.annotation
d'RHS is typeast.expr
, therefore I'm an idiot for assigning it tonode.annotation
d'LHS because it clearly has typeast.expr | None
. But maybe my quantum computer is causing this superposition of type states.One example
What should I do?
Some things that might contribute to a solution:
Repos for masochists
The code is in astToolkit, but most of that package is generated by astToolFactory. Those packages exist because I transform copious amounts of code in mapFolding.
Many tests
Beta Was this translation helpful? Give feedback.
All reactions