Skip to content

Conversation

AlexWaygood
Copy link
Member

Summary

Protocols can have method members, and those method members can have generic contexts. The generic context of a protocol's method members can be scoped to the class or the method itself.

We currently have some "accidental integration tests" for generic method members in our named-tuple test suite, but no explicit unit tests in protocols.md. This PR adds them.

Test Plan

cargo test -p ty_python_semantic --test=mdtest

@AlexWaygood AlexWaygood added the testing Related to testing Ruff itself label Sep 9, 2025
@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Sep 9, 2025
@AlexWaygood AlexWaygood changed the title [ty] Add explicit unit tests for protocols with method members with function-scoped generic contexts [ty] Add explicit unit tests for protocols with generic method members Sep 9, 2025
@AlexWaygood AlexWaygood changed the title [ty] Add explicit unit tests for protocols with generic method members [ty] Add tests for protocols with generic method members Sep 9, 2025
@AlexWaygood AlexWaygood force-pushed the alex/generic-method-tests branch from ec061c2 to 1c2bb3e Compare September 9, 2025 13:58
Copy link
Contributor

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you.

@AlexWaygood AlexWaygood force-pushed the alex/generic-method-tests branch from aef602f to 7b94e44 Compare September 9, 2025 16:39
@AlexWaygood AlexWaygood changed the base branch from alex/protocol-nominal to main September 9, 2025 16:40
@AlexWaygood AlexWaygood enabled auto-merge (squash) September 9, 2025 16:40
@AlexWaygood AlexWaygood merged commit bf66178 into main Sep 9, 2025
34 checks passed
@AlexWaygood AlexWaygood deleted the alex/generic-method-tests branch September 9, 2025 16:44
Copy link
Contributor

github-actions bot commented Sep 9, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+265 -0 violations, +0 -0 fixes in 2 projects; 53 projects unchanged)

apache/airflow (+3 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL

+ providers/common/sql/src/airflow/providers/common/sql/hooks/sql.pyi:112:10: UP043 [*] Unnecessary default type arguments
+ providers/common/sql/src/airflow/providers/common/sql/hooks/sql.pyi:146:10: UP043 [*] Unnecessary default type arguments
+ providers/common/sql/src/airflow/providers/common/sql/hooks/sql.pyi:156:10: UP043 [*] Unnecessary default type arguments

python/typeshed (+262 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select E,F,FA,I,PYI,RUF,UP,W

+ stdlib/argparse.pyi:315:60: UP043 [*] Unnecessary default type arguments
+ stdlib/codecs.pyi:198:83: UP043 [*] Unnecessary default type arguments
+ stdlib/codecs.pyi:199:85: UP043 [*] Unnecessary default type arguments
+ stdlib/concurrent/futures/process.pyi:100:53: UP043 [*] Unnecessary default type arguments
+ stdlib/email/message.pyi:133:23: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/fixes/fix_except.pyi:9:42: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/fixes/fix_import.pyi:8:32: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/fixes/fix_imports.pyi:11:35: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/fixes/fix_metaclass.pyi:11:29: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/fixes/fix_renames.pyi:10:24: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/fixes/fix_urllib.pyi:8:24: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/refactor.pyi:72:10: UP043 [*] Unnecessary default type arguments
+ stdlib/lib2to3/refactor.pyi:73:63: UP043 [*] Unnecessary default type arguments
+ stdlib/pathlib/__init__.pyi:183:80: UP043 [*] Unnecessary default type arguments
+ stdlib/pathlib/__init__.pyi:184:81: UP043 [*] Unnecessary default type arguments
+ stdlib/pathlib/__init__.pyi:186:41: UP043 [*] Unnecessary default type arguments
+ stdlib/pathlib/__init__.pyi:187:42: UP043 [*] Unnecessary default type arguments
+ stdlib/pathlib/__init__.pyi:202:26: UP043 [*] Unnecessary default type arguments
+ stdlib/sqlite3/__init__.pyi:367:61: UP043 [*] Unnecessary default type arguments
+ stdlib/sqlite3/__init__.pyi:369:31: UP043 [*] Unnecessary default type arguments
+ stdlib/tokenize.pyi:154:60: UP043 [*] Unnecessary default type arguments
+ stdlib/tokenize.pyi:155:53: UP043 [*] Unnecessary default type arguments
+ stdlib/traceback.pyi:114:90: UP043 [*] Unnecessary default type arguments
+ stdlib/traceback.pyi:235:96: UP043 [*] Unnecessary default type arguments
+ stdlib/traceback.pyi:237:52: UP043 [*] Unnecessary default type arguments
+ stdlib/traceback.pyi:240:90: UP043 [*] Unnecessary default type arguments
+ stdlib/traceback.pyi:242:44: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementPath.pyi:11:72: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementPath.pyi:14:80: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementPath.pyi:35:90: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementTree.pyi:109:47: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementTree.pyi:113:80: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementTree.pyi:114:27: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementTree.pyi:161:47: UP043 [*] Unnecessary default type arguments
+ stdlib/xml/etree/ElementTree.pyi:171:80: UP043 [*] Unnecessary default type arguments
+ stubs/JACK-Client/jack/__init__.pyi:240:39: UP043 [*] Unnecessary default type arguments
+ stubs/PyScreeze/pyscreeze/__init__.pyi:111:6: UP043 [*] Unnecessary default type arguments
+ stubs/PyScreeze/pyscreeze/__init__.pyi:123:6: UP043 [*] Unnecessary default type arguments
+ stubs/PyScreeze/pyscreeze/__init__.pyi:205:6: UP043 [*] Unnecessary default type arguments
+ stubs/PyScreeze/pyscreeze/__init__.pyi:217:6: UP043 [*] Unnecessary default type arguments
+ stubs/Pygments/pygments/filters/__init__.pyi:10:26: UP043 [*] Unnecessary default type arguments
+ stubs/Pygments/pygments/formatters/__init__.pyi:22:29: UP043 [*] Unnecessary default type arguments
+ stubs/Pygments/pygments/plugin.pyi:24:29: UP043 [*] Unnecessary default type arguments
+ stubs/Pygments/pygments/plugin.pyi:25:33: UP043 [*] Unnecessary default type arguments
+ stubs/Pygments/pygments/plugin.pyi:26:29: UP043 [*] Unnecessary default type arguments
+ stubs/Pygments/pygments/plugin.pyi:27:30: UP043 [*] Unnecessary default type arguments
+ stubs/antlr4-python3-runtime/antlr4/ParserRuleContext.pyi:32:46: UP043 [*] Unnecessary default type arguments
+ stubs/antlr4-python3-runtime/antlr4/RuleContext.pyi:26:30: UP043 [*] Unnecessary default type arguments
+ stubs/assertpy/assertpy/assertpy.pyi:64:26: UP043 [*] Unnecessary default type arguments
... 213 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
UP043 265 265 0 0 0

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

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

Labels

testing Related to testing Ruff itself ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants