Make Message.__getattribute__ invisible to type checkers (#359)

This lets linters know that we shouldn't access fields that aren't actually defined
This commit is contained in:
James Hilton-Balfe 2022-04-21 15:44:55 +01:00 committed by GitHub
parent 402c21256f
commit b9b0b22d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,7 @@ from datetime import (
timezone, timezone,
) )
from typing import ( from typing import (
TYPE_CHECKING,
Any, Any,
Callable, Callable,
Dict, Dict,
@ -693,6 +694,8 @@ class Message(ABC):
] ]
return f"{self.__class__.__name__}({', '.join(parts)})" return f"{self.__class__.__name__}({', '.join(parts)})"
if not TYPE_CHECKING:
def __getattribute__(self, name: str) -> Any: def __getattribute__(self, name: str) -> Any:
""" """
Lazily initialize default values to avoid infinite recursion for recursive Lazily initialize default values to avoid infinite recursion for recursive