rspec/rules/S2823/python/rule.adoc

61 lines
940 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
``++__all__++`` is used to define the list of module's names that should be imported when ``++from package import *++`` is used. For that reason, it may only contain strings.
=== Noncompliant code example
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
class MyClass:
pass
__all__ = [
MyClass # Noncompliant
]
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,python]
2021-04-28 16:49:39 +02:00
----
class MyClass:
pass
__all__ = [
"MyClass"
]
----
== Resources
2021-04-28 16:49:39 +02:00
* 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
Replace this symbol with a string; "__all__" can only contain strings.
=== Highlighting
Primary: the wrong symbol in "__all__"
'''
== Comments And Links
(visible only on this page)
=== is related to: S5807
endif::env-github,rspecator-view[]