Replies: 1 comment 1 reply
-
|
That's perfectly valid runtime-wise, though it's a type error (a function is not assignable to value: list[str] | None
if something:
value = ["a", "b"]
else:
value = NoneAssignments don't replace annotations. That said this probably isn't the best idea since type checkers are going to complain. |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
someone here stumbled upon this oddity:
Because
Foo.bazis typed asint, it shows up in__annotations__andget_annotations()even though it was replaced by a function:is that....a defined behavior? Can a library give this pattern to users and rely upon it working? use case is we are creating dataclasses where some of the attributes come from a descriptor, which normally is not in
__annotations__so we have to stuff that value into a custom__annotations__, which we'd rather not do.Beta Was this translation helpful? Give feedback.
All reactions