Skip to content

Commit

Permalink
Fix crash in the visitor implementation (#10)
Browse files Browse the repository at this point in the history
It was assumed to always be inside a class, which isn't
true in a lot of cases
  • Loading branch information
Viicos committed May 6, 2024
1 parent cd82d49 commit bf0572d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/flake8_pydantic/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def leave_class(self) -> None:
self.class_stack.pop()

@property
def current_class(self) -> ClassType:
def current_class(self) -> ClassType | None:
if not self.class_stack:
return None
return self.class_stack[-1]

def _check_pyd_001(self, node: ast.AnnAssign) -> None:
Expand Down

0 comments on commit bf0572d

Please sign in to comment.