Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

[ENH] Refactoring nested if structure #21

Closed
Anselmoo opened this issue Feb 6, 2022 · 1 comment
Closed

[ENH] Refactoring nested if structure #21

Anselmoo opened this issue Feb 6, 2022 · 1 comment

Comments

@Anselmoo
Copy link

Anselmoo commented Feb 6, 2022

Thx for the plugin!

Some of the if-if statements can be summarized via if + and

Maybe that's something to consider

if isinstance(el, ast.Assign):
if len(el.targets) == 1:
target = el.targets[0]
if isinstance(target, ast.Name):
if target.id == "__version__":
value_node = el.value
if isinstance(value_node, ast.Constant):
version = value_node.value
elif isinstance(value_node, ast.Str):
version = value_node.s
else: # pragma: nocover
# This is actually covered by tests, but can't be
# reported by Coverage
# Ref: https://github.com/nedbat/coveragepy/issues/198
continue
io.write_line(
"<b>poetry-version-plugin</b>: Setting package "
"dynamic version to __version__ "
f"variable from __init__.py: <b>{version}</b>"
)
poetry.package.set_version(version)

Anselmoo added a commit to Anselmoo/poetry-version-plugin that referenced this issue Feb 6, 2022
Refactoring `if-if` statements

Assignment Expressions via `:=`
@Anselmoo Anselmoo changed the title [ENC] Refactoring nested if structure [ENH] Refactoring nested if structure Feb 6, 2022
Anselmoo added a commit to Anselmoo/poetry-version-plugin that referenced this issue Jul 11, 2023
Refactoring `if-if` statements

Assignment Expressions via `:=`
@tiangolo
Copy link
Owner

tiangolo commented Sep 8, 2024

Thanks for the patience with my reply! 😅

I just marked this project as deprecated, I'm currently not using it and I think these ideas can be achieved in better ways: https://github.com/tiangolo/poetry-version-plugin#-warning-deprecated-

Given that I'll close this one, but thanks for the interest! ☕

@tiangolo tiangolo closed this as completed Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants