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

DX-780: Avoid guessing common words/module names #275

Merged

Conversation

blast-hardcheese
Copy link
Collaborator

@blast-hardcheese blast-hardcheese commented Jul 25, 2024

Why

pypi permits packages with extraordinarily common names (utils) as well as misconfigured packages (gardener-cicd-base, in this case, pollutes site-packages with util.py, model/, and ci/, among others)

What changed

I crossreferenced top-level packages discovered from pypi packages with /usr/share/dict/words then hand-pruned down to what I believe is a sensible list of names that can be common internal module names for projects, as well as excluding names that are popular pypi packages.

If there are any incorrect or missing entries, we can tune this over time, this is just trying to prevent import util guessing random stuff.

  • Add a wordlist
  • Delete guesses based on inclusion in the wordlist

Test plan

Before

$ echo $'import util\nimport utils' > main.py
$ upm guess --force
gardener-cicd-base
utils

After

$ echo $'import util\nimport utils' > main.py
$ upm guess --force
$

@blast-hardcheese blast-hardcheese added bug Something isn't working minor labels Jul 25, 2024
@blast-hardcheese blast-hardcheese requested a review from a team as a code owner July 25, 2024 18:29
@blast-hardcheese blast-hardcheese requested review from cdmistman and removed request for a team July 25, 2024 18:29
Copy link
Contributor

@cdmistman cdmistman left a comment

Choose a reason for hiding this comment

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

nice

@blast-hardcheese blast-hardcheese merged commit 5af79fa into main Jul 26, 2024
3 checks passed
@blast-hardcheese blast-hardcheese deleted the dstewart/DX-780/exclude-common-names-from-guess branch July 26, 2024 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants