Skip to content

Add documentation for cyclic-import#8322

Merged
jacobtylerwalls merged 4 commits intopylint-dev:mainfrom
Pierre-Sassoulas:doc-cyclic-import-example
Jun 18, 2023
Merged

Add documentation for cyclic-import#8322
jacobtylerwalls merged 4 commits intopylint-dev:mainfrom
Pierre-Sassoulas:doc-cyclic-import-example

Conversation

@Pierre-Sassoulas
Copy link
Copy Markdown
Member

@Pierre-Sassoulas Pierre-Sassoulas commented Feb 21, 2023

Type of Changes

Type
📜 Docs

Description

Work in progress for cyclic-import documentation. Right now it's not triggered. Refs #7897

@Pierre-Sassoulas Pierre-Sassoulas added Documentation 📗 Skip news 🔇 This change does not require a changelog entry Needs take over 🛎️ Orignal implementer went away but the code could be salvaged. labels Feb 21, 2023
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 21, 2023

Codecov Report

Merging #8322 (8e5f746) into main (81917bc) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #8322   +/-   ##
=======================================
  Coverage   95.84%   95.84%           
=======================================
  Files         173      173           
  Lines       18492    18492           
=======================================
  Hits        17724    17724           
  Misses        768      768           

@ollie-iterators
Copy link
Copy Markdown
Contributor

ollie-iterators commented Feb 25, 2023

I decided to check out your documentation for cyclic import. I was able to fix some things by adding import sys and then sys.path.append('...') (That fixed the relative-beyond-top-level error), but I keep getting an error saying that:

"/messages/c/cyclic-import/bad/bad2.py:2: in
from bad import count_to_one
doc/data/messages/c/cyclic-import/bad/bad.py:2: in
from bad2 import count_to_two # [cyclic-import]
E ImportError: cannot import name 'count_to_two' from partially initialized module 'bad2' (most likely due to a circular import)"

@Pierre-Sassoulas
Copy link
Copy Markdown
Member Author

Ha right, cyclic-import is a python error we need to import inside the function in Bad.py. thank you for investigating

@ollie-iterators
Copy link
Copy Markdown
Contributor

You're welcome

@ollie-iterators
Copy link
Copy Markdown
Contributor

ollie-iterators commented Feb 26, 2023

It also means you can document relative-beyond-top-level, which is not documented.

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the doc-cyclic-import-example branch from 28a0bff to ac45dab Compare February 26, 2023 15:36
@Pierre-Sassoulas
Copy link
Copy Markdown
Member Author

Seem like it work when using the parent directory. The recursive option does not help.

$ pylint /home/pierre/pylint/doc/data/messages/c/cyclic-import/bad --disable=all --enable=F,cyclic-import,astroid-error,syntax-error  
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 0.00/10, +10.00)

$  pylint /home/pierre/pylint/doc/data/messages/c/cyclic-import --disable=all --enable=F,cyclic-import,astroid-error,syntax-error 

************* Module bad.bad
doc/data/messages/c/cyclic-import/bad/bad.py:1:0: R0401: Cyclic import (bad.bad -> bad.bad2) (cyclic-import)
------------------------------------------------------------------
Your code has been rated at 9.29/10 (previous run: 8.57/10, +0.71)

@Pierre-Sassoulas Pierre-Sassoulas force-pushed the doc-cyclic-import-example branch from ac45dab to 60374a0 Compare March 3, 2023 19:16
Example of cyclic import where the cyclic import does not crash python
@Pierre-Sassoulas Pierre-Sassoulas force-pushed the doc-cyclic-import-example branch from 60374a0 to 8fe826e Compare May 3, 2023 20:59
@jacobtylerwalls jacobtylerwalls removed the Needs take over 🛎️ Orignal implementer went away but the code could be salvaged. label Jun 18, 2023
@jacobtylerwalls
Copy link
Copy Markdown
Member

Resolved this with an __init__.py to make /bad a package. Similar to #8772.

@jacobtylerwalls jacobtylerwalls enabled auto-merge (squash) June 18, 2023 17:19
@jacobtylerwalls jacobtylerwalls merged commit 5bb1fd1 into pylint-dev:main Jun 18, 2023
@Pierre-Sassoulas Pierre-Sassoulas deleted the doc-cyclic-import-example branch June 18, 2023 18:12
@Pierre-Sassoulas
Copy link
Copy Markdown
Member Author

Thank you so much @jacobtylerwalls !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation 📗 Skip news 🔇 This change does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants