Replies: 2 comments 7 replies
-
We strictly adhere to the principle that pyright does not implement any special-case knowledge of third-party libraries. If you want to extend Is the injected Could you provide a code sample that demonstrates the current undesirable behavior for attrs users when they're using pyright / pylance? |
Beta Was this translation helpful? Give feedback.
-
Hi @erictraut, would you be able to offer your input at python-attrs/attrs#999 if you've got time? |
Beta Was this translation helpful? Give feedback.
-
The 22.1.0 release of attrs introduced a typing-only protocol (not available at runtime) with one member,
__attrs_attrs__
, to identify attrs classes by (python-attrs/attrs#890). The protocol was used to annotate a number of core functions which take an attrs class as an argument. Previously, the attrs mypy plug-in was updated to "inject" the__attrs_attrs__
attribute to classes transformed by attrs' decorators (python/mypy#8578). For the discussion that motivated this change, see python-attrs/attrs#952.Is there something that Pyright could do to accommodate attrs here without burdering the users of the library - perhaps by extending
dataclass_transform
with the option to register a distinguishing attribute or a protocol that the transformed class is expected to conform to? I suppose the proper way to express this relationship is with an intersection of the original class and the protocol; but typing support for intersections seems to be a long way away.cc @Tinche
Beta Was this translation helpful? Give feedback.
All reactions