__slots__ should not be a single string
このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。
ID: python-best-practices/slots-no-single-string
Language: Python
Severity: Error
Category: Error Prone
Description
The __slots__
attribute must be a non-string iterable.
Learn More
Non-Compliant Code Examples
class MyClass:
__slots__ = "attr" # should be an iterable
def __init__(self):
pass
Compliant Code Examples
from django.apps import AppConfig
class TweetsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'tweets'
class MyClass:
__slots__ = ("attr", )
def __init__(self):
pass
Seamless integrations. Try Datadog Code Analysis