Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Jun 1, 2025

Close and reopen this PR to trigger CI

@github-actions github-actions bot added the internal An internal refactor or improvement label Jun 1, 2025
@AlexWaygood AlexWaygood closed this Jun 1, 2025
@AlexWaygood AlexWaygood reopened this Jun 1, 2025
@github-actions
Copy link
Contributor Author

github-actions bot commented Jun 1, 2025

mypy_primer results

Changes were detected when running on open source projects
pytest (https://github.com/pytest-dev/pytest)
+ error[unknown-argument] src/_pytest/assertion/rewrite.py:735:55: Argument `lineno` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] src/_pytest/assertion/rewrite.py:735:70: Argument `col_offset` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] src/_pytest/assertion/rewrite.py:739:21: Argument `lineno` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] src/_pytest/assertion/rewrite.py:740:21: Argument `col_offset` does not match any known parameter of bound method `__init__`
- Found 882 diagnostics
+ Found 886 diagnostics

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ error[unknown-argument] ddtrace/appsec/_iast/_ast/visitor.py:424:21: Argument `lineno` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] ddtrace/appsec/_iast/_ast/visitor.py:425:21: Argument `col_offset` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] ddtrace/appsec/_iast/_ast/visitor.py:439:21: Argument `lineno` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] ddtrace/appsec/_iast/_ast/visitor.py:440:21: Argument `col_offset` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] ddtrace/appsec/_iast/_ast/visitor.py:454:21: Argument `lineno` does not match any known parameter of bound method `__init__`
+ error[unknown-argument] ddtrace/appsec/_iast/_ast/visitor.py:455:21: Argument `col_offset` does not match any known parameter of bound method `__init__`
- Found 6854 diagnostics
+ Found 6860 diagnostics

@AlexWaygood
Copy link
Member

The primer hits are from python/typeshed#14103. It's interesting that there was no primer fallout in the typeshed PR there. I think this is because typeshed just runs primer with mypy on Python 3.13, so it didn't see any effect from a change that only effects sys.version_info < (3, 10) branches. But in our primer runs on this repo, we use whatever the project has in their pyproject.toml for the configured Python version, and pytest says they support 3.9+ -- so we assumed Python 3.9 when type-checking pytest in the mypy_primer run.

The change to the attribute annotations in that typeshed PR seem definitely correct, since ast.alias objects created by the interpreter won't ever have those attributes, so you cannot guarantee that any arbitrary ast.alias node will have those attributes on Python <3.10. But it's the changes to __init__ that are causing the primer hits here. I'm not totally convinced that those changes are useful, since ast.alias.__init__ doesn't actually raise an exception if you pass those keywords when you're manually constructing ast.alias nodes on Python <3.10 (it even sets the attributes in the way you'd expect), and the change makes it harder to write code that type-checks on multiple Python versions.

~/dev % uv run -p3.9 --no-project python
Python 3.9.6 (default, Mar 12 2025, 20:22:46) 
[Clang 17.0.0 (clang-1700.0.13.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> ast.alias("foo", col_offset=39)
<ast.alias object at 0x10429deb0>
>>> _.col_offset
39

Cc. @JelleZijlstra -- curious for your thoughts on this!

@AlexWaygood AlexWaygood merged commit 7a63ac1 into main Jun 1, 2025
35 checks passed
@AlexWaygood AlexWaygood deleted the typeshedbot/sync-typeshed branch June 1, 2025 14:21
@JelleZijlstra
Copy link
Contributor

I think it would be confusing if we allowed those attributes to be passed to __init__ but not accessed as attributes.

dcreager added a commit that referenced this pull request Jun 2, 2025
…aration

* origin/main:
  [ty] Treat lambda functions as instances of types.FunctionType (#18431)
  [ty] Fix false positives for legacy `ParamSpec`s inside `Callable` type expressions (#18426)
  [ty] Improve diagnostics if the user attempts to import a stdlib module that does not exist on their configured Python version (#18403)
  Update taiki-e/install-action action to v2.52.4 (#18420)
  Update docker/build-push-action action to v6.18.0 (#18422)
  [ty] Fix server hang after shutdown request (#18414)
  Update Rust crate libcst to v1.8.0 (#18424)
  Update Rust crate clap to v4.5.39 (#18419)
  Update cargo-bins/cargo-binstall action to v1.12.6 (#18416)
  Update dependency mdformat-mkdocs to v4.3.0 (#18421)
  Update pre-commit dependencies (#18418)
  Update dependency ruff to v0.11.12 (#18417)
  [ty] Ensure `Literal` types are considered assignable to anything their `Instance` supertypes are assignable to (#18351)
  [ty] Promote projects to good that now no longer hang (#18370)
  Sync vendored typeshed stubs (#18407)
  [ty] Fix multithreading related hangs and panics (#18238)
  Support relative `--ty-path` in ty-benchmark (#18385)
  [ty] Update docs for Python version inference (#18397)
  [ty] Infer the Python version from the environment if feasible (#18057)
  Implement template strings (#17851)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal An internal refactor or improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants