Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT: fix compatibility with Python 3.14 #684

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions flit_core/flit_core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ def get_docstring_and_version_via_ast(target):
with target_path.open('rb') as f:
node = ast.parse(f.read())
for child in node.body:
if sys.version_info >= (3, 8):
target_type = ast.Constant
else:
target_type = ast.Str
# Only use the version from the given module if it's a simple
# string assignment to __version__
is_version_str = (
Expand All @@ -157,10 +161,13 @@ def get_docstring_and_version_via_ast(target):
and target.id == "__version__"
for target in child.targets
)
and isinstance(child.value, ast.Str)
and isinstance(child.value, target_type)
)
if is_version_str:
version = child.value.s
if sys.version_info >= (3, 8):
version = child.value.value
else:
version = child.value.s
break
return ast.get_docstring(node), version

Expand Down