Skip to content

Commit 9cdefd9

Browse files
derek73claude
andcommitted
Fix docs build by guarding Self import behind version check
typing_extensions is only a dependency for Python < 3.11, but the unconditional import caused ModuleNotFoundError on ReadTheDocs (Python 3.12). Use typing.Self from stdlib on 3.11+ and fall back to typing_extensions on older versions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 551023c commit 9cdefd9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

nameparser/config/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
from collections.abc import Iterable, Iterator, Mapping, Set
3333
from typing import Any, TypeVar
3434

35-
from typing_extensions import Self
35+
if sys.version_info >= (3, 11):
36+
from typing import Self
37+
else:
38+
from typing_extensions import Self
3639

3740
from nameparser.util import lc
3841
from nameparser.config.prefixes import PREFIXES

0 commit comments

Comments
 (0)