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

runtime-evaluated-decorators not working for the annotations of decorated functions. #10089

Closed
DetachHead opened this issue Feb 23, 2024 · 2 comments · Fixed by #10091
Closed
Assignees

Comments

@DetachHead
Copy link

from __future__ import annotations

from pydantic import validate_call
from asdf import Foo # error: TCH002: Move third-party import `asdf.Foo` into a type-checking block

@validate_call
def a(value: Foo): ...

config:

{
  "lint": {
    "select": [
      "TCH"
    ],
    "flake8-type-checking": {"runtime-evaluated-decorators": ["pydantic.validate_call"]}
  }
}

playground

@charliermarsh
Copy link
Member

I'll take a look now.

@charliermarsh charliermarsh self-assigned this Feb 23, 2024
@charliermarsh
Copy link
Member

It looks like these are applied for assignments within function bodies, but not annotations on function signatures (parameters and return types).

charliermarsh added a commit that referenced this issue Feb 23, 2024
## Summary

The original implementation of this applied the runtime-required context
to definitions _within_ the function, but not the signature itself. (We
had test coverage; the snapshot was just correctly showing the wrong
outcome.)

Closes #10089.
nkxxll pushed a commit to nkxxll/ruff that referenced this issue Mar 10, 2024
…h#10091)

## Summary

The original implementation of this applied the runtime-required context
to definitions _within_ the function, but not the signature itself. (We
had test coverage; the snapshot was just correctly showing the wrong
outcome.)

Closes astral-sh#10089.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants