
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
59 lines
1.1 KiB
Plaintext
59 lines
1.1 KiB
Plaintext
== Why is this an issue?
|
|
|
|
Developers may define a list named ``++__all__++`` in a module to limit the names imported from it by wildcard imports (``++from mymodule import *++``). This list can only reference defined names, otherwise an ``++AttributeError++`` will be raised when the module is imported.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,python]
|
|
----
|
|
from mymodule import my_func
|
|
|
|
__all__ = ["unknown_func"] # Noncompliant. "unknown_func" is undefined
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,python]
|
|
----
|
|
from mymodule import my_func
|
|
|
|
__all__ = ["my_func"]
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* https://docs.python.org/3/tutorial/modules.html#importing-from-a-package[Python documentation - Importing * From a Package]
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Change or remove this string; "XX" is not defined.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
* Primary: The string with an undefined name.
|
|
* Secondary: the variable assignment if a variable is used.
|
|
message: 'Assigned here.'
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== relates to: S2823
|
|
|
|
=== relates to: S3827
|
|
|
|
endif::env-github,rspecator-view[]
|