このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。

Metadata

ID: python-best-practices/any-type-disallow

Language: Python

Severity: Warning

Category: Error Prone

Description

Use the Any type very carefully. Most of the time, the Any type is used because we do not know exactly what type is being used. If you want to specify that a value can be of any type, use object instead of Any.

Learn More

Non-Compliant Code Examples

my_var: Any = 1
def foo(x: Any):  # do not use Any, use a specific type
   pass

Compliant Code Examples

my_var: int = 1

def my_function(a: str) -> str:
    pass
https://static.datadoghq.com/static/images/logos/github_avatar.svg https://static.datadoghq.com/static/images/logos/vscode_avatar.svg jetbrains

Seamless integrations. Try Datadog Code Analysis