Skip to content

Commit

Permalink
Add documentation for cyclic-import (#8322)
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
  • Loading branch information
Pierre-Sassoulas and jacobtylerwalls authored Jun 18, 2023
1 parent 81917bc commit 5bb1fd1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
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

0 comments on commit 5bb1fd1

Please sign in to comment.