Skip to content

[red-knot] Implicit instance attributes in generic methods#17769

Merged
sharkdp merged 3 commits intomainfrom
david/fix-16928
May 2, 2025
Merged

[red-knot] Implicit instance attributes in generic methods#17769
sharkdp merged 3 commits intomainfrom
david/fix-16928

Conversation

@sharkdp
Copy link
Contributor

@sharkdp sharkdp commented May 1, 2025

Summary

Add the ability to detect instance attribute assignments in class methods that are generic.

This does not address the code duplication mentioned in #16928. I can open a ticket for this after this has been merged.

closes #16928

Test Plan

Added regression test.

@sharkdp sharkdp added the ty Multi-file analysis & type inference label May 1, 2025
@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2025

mypy_primer results

No ecosystem changes detected ✅

@sharkdp sharkdp force-pushed the david/fix-16928 branch from a3331da to bd0515a Compare May 1, 2025 20:04
@sharkdp sharkdp marked this pull request as ready for review May 1, 2025 20:07
Copy link
Contributor

@carljm carljm 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!

@sharkdp sharkdp closed this May 2, 2025
@sharkdp sharkdp reopened this May 2, 2025
@sharkdp sharkdp force-pushed the david/fix-16928 branch from fdb69bb to 8a1e635 Compare May 2, 2025 08:17
@sharkdp sharkdp requested a review from MichaReiser as a code owner May 2, 2025 08:17
@sharkdp sharkdp enabled auto-merge (squash) May 2, 2025 08:18
@sharkdp sharkdp merged commit 3cf44e4 into main May 2, 2025
34 checks passed
@sharkdp sharkdp deleted the david/fix-16928 branch May 2, 2025 08:20
Copy link
Member

Choose a reason for hiding this comment

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

TIL about this directory! As an aside, do we have a convention for choosing which number to use as the prefix for the test cases in here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not really, and I think we've even added some without numbers. The numbers are legacy (we inherited this corpus) and I don't think they serve much purpose, we could just do a pass to remove them. I guess if they serve any purpose it's to keep related tests next to each other in a lexicographic ordering? But that can also just be done with naming.

dcreager added a commit that referenced this pull request May 2, 2025
* main:
  [red-knot] Refactor: no mutability in call APIs (#17788)
  [red-knot] Fix panic for `tuple[x[y]]` string annotation (#17787)
  [red-knot] Implicit instance attributes in generic methods (#17769)
  doc: Add link to `check-typed-exception` from `S110` and `S112` (#17786)
  Fix module name in ASYNC110, 115, and 116 fixes (#17774)
  [red-knot] More informative hover-types for assignments (#17762)
  [syntax-errors] Use consistent message for bad starred expression usage. (#17772)
  red_knot_server: add auto-completion MVP
  Allow passing a virtual environment to `ruff analyze graph` (#17743)
  Bump 0.11.8 (#17766)
  [`flake8-use-pathlib`] Fix `PTH104`false positive when `rename` is passed a file descriptor (#17712)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[red-knot] detect implicit instance attributes in a generic method

4 participants