Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference to runtime-evaluated-base-classes in the same file don't work #8250

Closed
iurisilvio opened this issue Oct 26, 2023 · 3 comments · Fixed by #8572
Closed

Reference to runtime-evaluated-base-classes in the same file don't work #8250

iurisilvio opened this issue Oct 26, 2023 · 3 comments · Fixed by #8572
Assignees
Labels
bug Something isn't working

Comments

@iurisilvio
Copy link

For some reason, semantic.resolve_call_path(map_subscript(base)) resolves to None when the reference is in the same file.

semantic
.resolve_call_path(map_subscript(base))

  • A minimal code snippet that reproduces the bug.

In this example, example1.MyBaseClass is a runtime evaluated base class.

example1.py

This triggers TCH003 for Sequence.

from __future__ import annotations

from collections.abc import Sequence  # TCH003


class MyBaseClass:
    pass


class Foo(MyBaseClass):
    foo: Sequence

example2.py

This is TCH compliant.

from __future__ import annotations

from collections.abc import Sequence

from example1 import MyBaseClass


class Foo(MyBaseClass):
    foo: Sequence
  • The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.

ruff --select TCH example1.py example2.py

  • The current Ruff settings (any relevant sections from your pyproject.toml).
[tool.ruff.flake8-type-checking]
runtime-evaluated-base-classes = [
  "example1.MyBaseClass",
]
  • The current Ruff version (ruff --version).

Main branch, currently 0.1.1.

@charliermarsh charliermarsh added the bug Something isn't working label Oct 26, 2023
@charliermarsh
Copy link
Member

Thanks! Similar to (or the same as) #5486.

@charliermarsh
Copy link
Member

I really appreciate that you dug into the code :)

@evanrittenhouse
Copy link
Contributor

Feel free to assign this to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants