SyntaxError: invalid character when running in Windows
seandearnaley opened this issue · 2 comments
Describe the bug
Tried this out today for the first time on a Windows machine, with a very simple repo that is using a requirements.txt but deptry throws an error- seems to trigger from a black related site package in lib:
Scanning 5229 files...
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\Scripts\deptry.exe\__main__.py", line 7, in <module>
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\click\core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\deptry\cli.py", line 230, in deptry
).run()
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\deptry\core.py", line 64, in run
for mod in get_imported_modules_for_list_of_files(all_python_files)
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\deptry\imports\extract.py", line 16, in get_imported_modules_for_list_of_files
unique_modules = set(itertools.chain.from_iterable(get_imported_modules_from_file(file) for file in list_of_files))
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\deptry\imports\extract.py", line 16, in <genexpr>
unique_modules = set(itertools.chain.from_iterable(get_imported_modules_from_file(file) for file in list_of_files))
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\deptry\imports\extract.py", line 30, in get_imported_modules_from_file
modules = PythonImportExtractor(path_to_file).extract_imports()
File "C:\Users\seand\OneDrive\Documents\GitHub\ScrapeStrike\scrapestrike\lib\site-packages\deptry\imports\extractors\python_import_extractor.py", line 17, in extract_imports
tree = ast.parse(python_file.read(), str(self.file))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "scrapestrike\Lib\site-packages\black\linegen.py", line 418
Ø: Set[str] = set()
^
SyntaxError: invalid character '˜' (U+02DC)
To Reproduce
Steps to reproduce the behavior:
- terminal to working directory
- activate venv
- run deptry .
Expected behavior
deptry output
System [please complete the following information]:
- OS: Windows 11
- Language Version: Python 3.10
Thanks for raising the issue @seandearnaley.
I assume your working directory is scrapestrike\
. It seems deptry
is also scanning files within scrapestrike/Lib/site-packages
to determine if there are issues with your project's dependencies, which is probably not what you want.
Try running
deptry . -ee Lib
or adding Lib
to the extend_exclude
argument in your [tool.deptry]
section in pyproject.toml
.
For more information, see this section of the documentation.
Hope this helps!
Closing, since I assume the issue has been resolved. If not, please let me know and I'll reopen the issue.