#122

Fix Attrs method annotation evaluation

Openiliyasonewants to merge intofrom

As I understand, Attrs[T] should inspect only class attributes, not methods. Previously, the Attrs path still called get_local_defns() in a mode that processed methods, which could execute PEP 649 __annotate__ functions before Attrs filtered anything out.

The problem is that some methods may not have good runtime annotations. For example, something like this:

if TYPE_CHECKING:
    class HiddenNamespace:
        pass

class Base:
    def rebuild(self, ns: HiddenNamespace | None = None) -> bool | None:
        return None

class Model(Base):
    name: str

Attrs[Model] should evaluate only Model.name and not raise an error, as evaluation of methods is not required for the Attribute types.

The bigger problem is that the runtime can't run the insides of the if TYPE_CHECKING block, and i guess there is nothing we can do about this

Activity

2
vercel[bot]5mo ago

@iliyasone is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.