Skip to content

Fix autoimport not scanning packages recursively#688

Merged
lieryan merged 3 commits intomasterfrom
lieryan-missing-symbols
Apr 18, 2023
Merged

Fix autoimport not scanning packages recursively#688
lieryan merged 3 commits intomasterfrom
lieryan-missing-symbols

Conversation

@lieryan
Copy link
Copy Markdown
Member

@lieryan lieryan commented Apr 18, 2023

Description

Change glob pattern in get_files() to scan site-packages recursively.

Fixes #687

Checklist (delete if not relevant):

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated CHANGELOG.md

@lieryan lieryan self-assigned this Apr 18, 2023
@lieryan lieryan added bug Unexpected or incorrect user-visible behavior autoimport labels Apr 18, 2023
@lieryan
Copy link
Copy Markdown
Member Author

lieryan commented Apr 18, 2023

cc: @bagel897 FYI, this is an issue raised by rstcruzo in #685. I hope I didn't missing anything obvious with this fix here.

@lieryan lieryan merged commit b9580da into master Apr 18, 2023
@lieryan lieryan deleted the lieryan-missing-symbols branch April 18, 2023 04:56
@bagel897
Copy link
Copy Markdown
Contributor

Shouldn't it be **.py? That way it'll glob root directory files.

@lieryan
Copy link
Copy Markdown
Member Author

lieryan commented Apr 18, 2023

Yeah, that's what I initially thought as well, but apparently, the glob.glob() and the pathlib glob doesn't really work the same.

Doing **.py is an error with pathlib's glob:

In [5]: list(Path(".").glob("**.py"))
ValueError: Invalid pattern: '**' can only be an entire path component

**/*.py looks unintuitive, but it does actually include the root directory files:

In [12]: list(Path(".").glob("**/*.py"))
Out[12]: 
[PosixPath('setup.py'),
...
]

OTOH, for glob.glob() stdlib module, **.py is basically identical to *.py:

In [10]: glob.glob("**.py", recursive=True)
Out[10]: ['setup.py']

and **/*.py works the same as pathlib's glob.

@bagel897
Copy link
Copy Markdown
Contributor

Weird

@lieryan lieryan added this to the 1.8.0 milestone May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoimport bug Unexpected or incorrect user-visible behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing symbols in autoimport.db

2 participants