Skip to content

Commit

Permalink
Clean up the check
Browse files Browse the repository at this point in the history
  • Loading branch information
dmontagu committed Oct 4, 2023
1 parent e82625f commit ce57907
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pydantic/mypy.py
Expand Up @@ -348,7 +348,7 @@ def to_argument(self, current_info: TypeInfo, typed: bool, force_optional: bool,
def expand_type(self, current_info: TypeInfo) -> Type | None:
"""Based on mypy.plugins.dataclasses.DataclassAttribute.expand_type."""
# The hasattr check in the next line is only necessary to prevent errors in old versions of mypy
if self.type is not None and hasattr(self.info, 'self_type') and self.info.self_type is not None:
if self.type is not None and getattr(self.info, 'self_type', None) is not None:
# In general, it is not safe to call `expand_type()` during semantic analyzis,
# however this plugin is called very late, so all types should be fully ready.
# Also, it is tricky to avoid eager expansion of Self types here (e.g. because
Expand Down

0 comments on commit ce57907

Please sign in to comment.