Skip to content

Conversation

@AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Oct 30, 2025

Summary

We weren't correctly modeling it as a staticmethod in all cases, leading us to incorrectly infer that the cls argument would be bound if it was accessed on an instance (rather than the class object).

Test Plan

Added mdtests that fail on main. The primer output also looks good!

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Oct 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

mypy_primer results

Changes were detected when running on open source projects
pip (https://github.com/pypa/pip) - src/pip/_vendor/rich/style.py:478:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - src/pip/_vendor/rich/style.py:630:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - src/pip/_vendor/rich/style.py:653:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - src/pip/_vendor/rich/style.py:676:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - src/pip/_vendor/rich/style.py:734:41: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - Found 582 diagnostics + Found 577 diagnostics rich (https://github.com/Textualize/rich) - rich/style.py:478:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - rich/style.py:630:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - rich/style.py:653:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - rich/style.py:676:37: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - rich/style.py:734:41: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - Found 321 diagnostics + Found 316 diagnostics zope.interface (https://github.com/zopefoundation/zope.interface) - src/zope/interface/interface.py:739:16: error[missing-argument] No arguments provided for required parameters `bases`, `attrs` of bound method `__new__` + src/zope/interface/interface.py:739:16: error[missing-argument] No arguments provided for required parameters `name`, `bases`, `attrs` of function `__new__` pycryptodome (https://github.com/Legrandin/pycryptodome) - lib/Crypto/Hash/CMAC.py:173:28: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 1, got 2 - Found 1775 diagnostics + Found 1774 diagnostics sympy (https://github.com/sympy/sympy) - sympy/physics/secondquant.py:1983:45: error[too-many-positional-arguments] Too many positional arguments to bound method `__new__`: expected 2, got 3 - Found 14031 diagnostics + Found 14030 diagnostics 
No memory usage changes detected ✅
@AlexWaygood AlexWaygood marked this pull request as ready for review October 30, 2025 17:08
@AlexWaygood AlexWaygood added the bug Something isn't working label Oct 30, 2025
@AlexWaygood AlexWaygood changed the title [ty] Fix lookup of __new__ [ty] Fix lookup of __new__ on instances Oct 30, 2025
@AlexWaygood AlexWaygood force-pushed the alex/fix-dunder-new-lookup branch from 933e8d6 to f7d24ad Compare October 30, 2025 17:11
@AlexWaygood AlexWaygood merged commit 9bacd19 into main Oct 30, 2025
41 checks passed
@AlexWaygood AlexWaygood deleted the alex/fix-dunder-new-lookup branch October 30, 2025 17:42
dcreager added a commit that referenced this pull request Oct 30, 2025
* origin/main: (21 commits) [ty] Update "constraint implication" relation to work on constraints between two typevars (#21068) [`flake8-type-checking`] Fix `TC003` false positive with `future-annotations` (#21125) [ty] Fix lookup of `__new__` on instances (#21147) Fix syntax error false positive on nested alternative patterns (#21104) [`pyupgrade`] Fix false positive for `TypeVar` with default on Python <3.13 (`UP046`,`UP047`) (#21045) [ty] Reachability and narrowing for enum methods (#21130) [ty] Use `range` instead of custom `IntIterable` (#21138) [`ruff`] Add support for additional eager conversion patterns (`RUF065`) (#20657) [`ruff-ecosystem`] Fix CLI crash on Python 3.14 (#21092) [ty] Infer type of `self` for decorated methods and properties (#21123) [`flake8-bandit`] Fix correct example for `S308` (#21128) [ty] Dont provide goto definition for definitions which are not reexported in builtins (#21127) [`airflow`] warning `airflow....DAG.create_dagrun` has been removed (`AIR301`) (#21093) [ty] follow the breaking API changes made in salsa-rs/salsa#1015 (#21117) [ty] Rename `Type::into_nominal_instance` (#21124) [ty] Filter out "unimported" from the current module [ty] Add evaluation test for auto-import including symbols in current module [ty] Refactor `ty_ide` completion tests [ty] Render `import <...>` in completions when "label details" isn't supported [`refurb`] Preserve digit separators in `Decimal` constructor (`FURB157`) (#20588) ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ty Multi-file analysis & type inference

3 participants