Skip to content

Commit

Permalink
Fixed deprecation warnings on Python 3.12
Browse files Browse the repository at this point in the history
Fixes #368.
  • Loading branch information
agronholm committed Jun 20, 2023
1 parent 91204af commit f377be3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/typeguard/_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,13 @@ def __post_init__(self) -> None:
if isinstance(child, ImportFrom) and child.module == "__future__":
# (module only) __future__ imports must come first
continue
elif isinstance(child, Expr) and isinstance(child.value, Str):
continue # docstring
elif isinstance(child, Expr):
if isinstance(child.value, Constant) and isinstance(
child.value.value, str
):
continue # docstring
elif sys.version_info < (3, 8) and isinstance(child.value, Str):
continue # docstring

self.code_inject_index = index
break
Expand Down

1 comment on commit f377be3

@musicinmybrain
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This works for me. (I backported it to 4.0.0 for Fedora Linux.)

Please sign in to comment.