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

Add documentation for cyclic-import #8322

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
8 changes: 8 additions & 0 deletions doc/data/messages/c/cyclic-import/bad/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def count_to_one():
return 1


def count_to_three():
from .bad2 import count_to_two

return count_to_two() + 1
5 changes: 5 additions & 0 deletions doc/data/messages/c/cyclic-import/bad/bad2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .bad import count_to_one # [cyclic-import]


def count_to_two():
return count_to_one() + 1
4 changes: 3 additions & 1 deletion doc/data/messages/c/cyclic-import/details.rst
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
You can help us make the doc better `by contributing <https://github.com/pylint-dev/pylint/issues/5953>`_ !
The good code is just an example. There are various strategies to resolving
cyclic imports and the best choice relies heavily on the context of the code
and the affected modules.
11 changes: 10 additions & 1 deletion doc/data/messages/c/cyclic-import/good.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# This is a placeholder for correct code for this message.
def count_to_one():
return 1


def count_to_two():
return count_to_one() + 1


def count_to_three():
return count_to_two() + 1