Skip to content

Use TYPE_CHECKING if necessary #6029

@nabenabe0928

Description

@nabenabe0928

Note

An example is available here:

Important

In order to reduce review costs and to encourage more contributors to work on it, please, as a rule, fix one file per PR. After one PR submission, please tackle other issues.

Motivation

Some modules are imported only for type checking, but this may cause circular import, leading to an error.
Although such an error is not a big deal for most cases, it may require annoying changes sometimes as in:

The issue above motivates using TYPE_CHECKING.

Suggestion

First, we can check which files to modify by the following:

$ ruff check . --select TCH

Additional context (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    code-fixChange that does not change the behavior, such as code refactoring.contribution-welcomeIssue that welcomes contribution.good first issueGood first issue for contribution.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions