Skip to content

Commit

Permalink
fix: handle __firstlineno__
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Aug 25, 2024
1 parent dc03e8c commit c4f1862
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def test_getsource_on_class_without_firstlineno():
__firstlineno__ = 0

class C:
nonlocal __firstlineno__
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,10 +1213,10 @@ def check_code(self, code, nodes, decorators, check_names):
continue

if (
inst.opname == "STORE_NAME"
inst.opname in ("STORE_NAME", "STORE_DEREF")
and hasattr(inst, "positions")
and inst.positions.col_offset == inst.positions.end_col_offset == 0
and inst.argval in ("__module__", "__qualname__")
and inst.argval in ("__module__", "__qualname__", "__firstlineno__")
):
continue

Expand Down

0 comments on commit c4f1862

Please sign in to comment.