Closed hc closed 6 months ago
you should use Annotated if you are using non pep 484 types as annotations
How that would look like in the example above with Annotated?
what have you tried? the docs for Annotated are fairly straightforward
This is a fairly big codebase, so I am looking for what we could update with minimum change to make it passes these checks
can you show me your attempt to use Annotated? I'm not sure what you're confused about so I can't help you unless you show me
Sure, trying different scenario with:
from typing import Annotated
from typing import Annotated as Aliased1
def somefunction(a, b):
return str
Aliased2 = Annotated
annoted: Annotated[int, somefunction(-10, "ok")] = None
annoted2: Aliased1[int, somefunction(-10, "ok")] = None
annoted3: Aliased2[int, somefunction(-10, "ok")] = None
As we rely on custom alias (and not just Annotated) with this the first one works with Annotated, by the Aliased1 and Aliased2 raise F821
that's a completely different problem than your issue and has several duplicates if you search around
Based on my initial example, what it would look like then using Annotated?
@hc what have you tried?
Here an example that raises a F821 error:
The error is then F821 undefined name 'something'
Is there any workaround (without disabling F821 on that specific line) or way to improve that particular scenario?