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

Imports within TYPE_CHECKING can induce "cyclic-import" #3525

Closed
NeilGirdhar opened this issue Apr 27, 2020 · 3 comments · Fixed by #4703
Closed

Imports within TYPE_CHECKING can induce "cyclic-import" #3525

NeilGirdhar opened this issue Apr 27, 2020 · 3 comments · Fixed by #4703
Labels
Bug 🪲 Help wanted 🙏 Outside help would be appreciated, good for new contributors High priority Issue with more than 10 reactions
Milestone

Comments

@NeilGirdhar
Copy link

NeilGirdhar commented Apr 27, 2020

Suppose you have two modules: a.py and b.py. a imports b, but b needs a in order to do type annotations, then this is usually done by importing a within a TYPE_CHECKING block. Unfortunately, this causes pylint to report cyclic-import.

Possibly related to #3285

@NeilGirdhar NeilGirdhar changed the title Imports TYPE_CHECKING induce "cyclic-import" Imports within TYPE_CHECKING induce "cyclic-import" Apr 27, 2020
@NeilGirdhar NeilGirdhar changed the title Imports within TYPE_CHECKING induce "cyclic-import" Imports within TYPE_CHECKING can induce "cyclic-import" Apr 27, 2020
@PCManticore PCManticore added this to the 2.5.2 release milestone May 5, 2020
@PCManticore PCManticore self-assigned this May 5, 2020
Parnassius added a commit to Parnassius/cerbottana that referenced this issue Aug 23, 2020
- too-many-* messages were temporarily disabled, and should be
re-enabled sooner or later
- cyclic-import should be re-enabled when pylint-dev/pylint#3525 is fixed
@ssbarnea
Copy link
Contributor

Not only this but they can produce very weir errors, ones reported to files that do not have any imports related to the cyclic ones inside, at least with current code from master. I cannot reproduce the problem with v2.6.0 release, but that one has other issues.

@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.7.0, 2.7.x Feb 20, 2021
AChenQ pushed a commit to AChenQ/tensorbay-python-sdk that referenced this issue Mar 16, 2021
error file path: tensorbay/opendataset/JHU_CROWD/loader.py
pylint will raise cyclic-import error at ubuntu18.04 python3.8.0
and will not raise error at ubuntu20.04 and macos.

4ylint related issue:
pylint-dev/pylint#3525
AChenQ pushed a commit to AChenQ/tensorbay-python-sdk that referenced this issue Mar 16, 2021
error file path: tensorbay/opendataset/JHU_CROWD/loader.py
pylint will raise cyclic-import error at ubuntu18.04 python3.8.0
and will not raise error at ubuntu20.04 and macos.

pylint related issue:
pylint-dev/pylint#3525
AChenQ pushed a commit to Graviti-AI/tensorbay-python-sdk that referenced this issue Mar 16, 2021
error file path: tensorbay/opendataset/JHU_CROWD/loader.py
pylint will raise cyclic-import error at ubuntu18.04 python3.8.0
and will not raise error at ubuntu20.04 and macos.

pylint related issue:
pylint-dev/pylint#3525
AChenQ pushed a commit to AChenQ/tensorbay-python-sdk that referenced this issue Mar 19, 2021
AChenQ pushed a commit to Graviti-AI/tensorbay-python-sdk that referenced this issue Mar 19, 2021
@Pierre-Sassoulas Pierre-Sassoulas added the High priority Issue with more than 10 reactions label May 30, 2021
@Pierre-Sassoulas Pierre-Sassoulas pinned this issue Jul 1, 2021
@Pierre-Sassoulas Pierre-Sassoulas added the Help wanted 🙏 Outside help would be appreciated, good for new contributors label Jul 1, 2021
@Pierre-Sassoulas Pierre-Sassoulas unpinned this issue Jul 20, 2021
@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 2.x, 2.10.0 Aug 4, 2021
@BobDotCom
Copy link

BobDotCom commented Nov 7, 2021

This issue appears to have been marked as resolved but I'm still running into it on pylint 2.11.1, python 3.9.7. The only thing that seems to fix it is using a block disable.

if TYPE_CHECKING:
    # pylint: disable=cyclic-import
    ...

Can anyone else confirm if they're experiencing this or if I misinterpreted the status of this issue?

@Pierre-Sassoulas
Copy link
Member

@BobDotCom any chance you could provide a reproducing example ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Help wanted 🙏 Outside help would be appreciated, good for new contributors High priority Issue with more than 10 reactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants