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

[bug] TCH004 false positive with function-scoped imports #4941

Closed
smackesey opened this issue Jun 7, 2023 · 2 comments
Closed

[bug] TCH004 false positive with function-scoped imports #4941

smackesey opened this issue Jun 7, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@smackesey
Copy link

I was unable to create a simple reproduction of this, but TCH004 on ruff 0.0.271 gives several false positives in Dagster when there are function-local imports. Running ruff on https://github.com/dagster-io/dagster/blame/master/python_modules/dagster/dagster/_core/definitions/op_definition.py will give this error:

python_modules/dagster/dagster/_core/definitions/op_definition.py:53:42: TCH004 [*] Move import `.decorators.op_decorator.DecoratedOpFunction` out of type-checking block. Import is used for more than type hinting.

But this isn't the case-- all the places where DecoratedOpFunction is used outside of type annotations, there is a function-local import covering it. When ruff autofixes this it pulls the import out of the TYPE_CHECKING block which then causes a circular import error.

@charliermarsh
Copy link
Member

Thanks, that's a helpful example.

@charliermarsh charliermarsh added the bug Something isn't working label Jun 7, 2023
@charliermarsh charliermarsh self-assigned this Jun 7, 2023
@charliermarsh
Copy link
Member

Oh, hah, this was also fixed by #4942.

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
Development

No branches or pull requests

2 participants