Skip to content

typing: make Protocol definition reflect runtime - #16386

Open
istoolsfox wants to merge 1 commit into
python:mainfrom
istoolsfox:typing-protocol-runtime
Open

typing: make Protocol definition reflect runtime#16386
istoolsfox wants to merge 1 commit into
python:mainfrom
istoolsfox:typing-protocol-runtime

Conversation

@istoolsfox

Copy link
Copy Markdown

Follow-up to #14583, which moved Generic from _SpecialForm to type[_Generic] and named Protocol as a future candidate for the same treatment. See python/mypy#21940.

Declare class _Protocol and use type[_Protocol] for typing.Protocol and typing_extensions.Protocol, mirroring Generic; remove the stubtest allowlist entries this makes unnecessary.

Agent used: ZCode (GLM)

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

beartype (https://github.com/beartype/beartype)
+ beartype/_util/hint/pep/proposal/pep544.py:115: error: Unused "type: ignore" comment  [unused-ignore]

trio (https://github.com/python-trio/trio)
+ src/trio/_tests/test_exports.py:36: error: Incompatible types in assignment (expression has type "type[typing._Protocol]", variable has type "type[typing_extensions._Protocol]")  [assignment]

DateType (https://github.com/glyph/DateType)
- src/datetype/__init__.py:29: error: Unused "type: ignore" comment  [unused-ignore]

dacite (https://github.com/konradhalas/dacite)
- dacite/data.py:4: error: Unused "type: ignore" comment  [unused-ignore]

meson (https://github.com/mesonbuild/meson)
+ mesonbuild/minstall.py:43:9: error: Incompatible import of "Protocol" (imported name has type "type[typing_extensions._Protocol]", local name has type "type[typing._Protocol]")  [assignment]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant