Skip to content

Implement function (and remove distutils dependency)#303

Merged
hakancelikdev merged 5 commits intomainfrom
distutils
Nov 17, 2023
Merged

Implement function (and remove distutils dependency)#303
hakancelikdev merged 5 commits intomainfrom
distutils

Conversation

@hakancelikdev
Copy link
Copy Markdown
Owner

No description provided.

@hakancelikdev hakancelikdev linked an issue Nov 17, 2023 that may be closed by this pull request
@hakancelikdev hakancelikdev merged commit f37ad76 into main Nov 17, 2023
@hakancelikdev hakancelikdev deleted the distutils branch November 17, 2023 18:41
Comment thread src/unimport/utils.py

@functools.lru_cache(maxsize=3)
def action_to_bool(action: str) -> bool:
if action == "":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe this introduced a regression. Before, when action == "", the function would return True. Now it will raise.

Comment thread src/unimport/utils.py
@@ -76,12 +74,19 @@ def is_std(package: str) -> bool:

@functools.lru_cache(maxsize=3)
Copy link
Copy Markdown
Contributor

@mxr mxr Nov 17, 2023

Choose a reason for hiding this comment

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

IMHO you would have a simpler, faster function by moving ("y", "yes", "t", "true", "on", "1") into a module-level $O(1)$ datastructure such as frozenset, and removing this cache

@mxr
Copy link
Copy Markdown
Contributor

mxr commented Nov 17, 2023

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unimport crashes on py3.12 due to distutils removal

2 participants