diff --git a/doc/data/messages/c/cyclic-import/bad/__init__.py b/doc/data/messages/c/cyclic-import/bad/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/doc/data/messages/c/cyclic-import/bad/bad.py b/doc/data/messages/c/cyclic-import/bad/bad.py new file mode 100644 index 0000000000..75e5e2bce0 --- /dev/null +++ b/doc/data/messages/c/cyclic-import/bad/bad.py @@ -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 diff --git a/doc/data/messages/c/cyclic-import/bad/bad2.py b/doc/data/messages/c/cyclic-import/bad/bad2.py new file mode 100644 index 0000000000..23417a821c --- /dev/null +++ b/doc/data/messages/c/cyclic-import/bad/bad2.py @@ -0,0 +1,5 @@ +from .bad import count_to_one # [cyclic-import] + + +def count_to_two(): + return count_to_one() + 1 diff --git a/doc/data/messages/c/cyclic-import/details.rst b/doc/data/messages/c/cyclic-import/details.rst index c1e9b976ac..5db72735cf 100644 --- a/doc/data/messages/c/cyclic-import/details.rst +++ b/doc/data/messages/c/cyclic-import/details.rst @@ -1 +1,3 @@ -You can help us make the doc better `by contributing `_ ! +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. diff --git a/doc/data/messages/c/cyclic-import/good.py b/doc/data/messages/c/cyclic-import/good.py index c40beb573f..7924246ef8 100644 --- a/doc/data/messages/c/cyclic-import/good.py +++ b/doc/data/messages/c/cyclic-import/good.py @@ -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