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

Pth file formatting breaks griffe #84

Closed
samrensenhouse opened this issue Jun 9, 2022 · 2 comments · Fixed by #85
Closed

Pth file formatting breaks griffe #84

samrensenhouse opened this issue Jun 9, 2022 · 2 comments · Fixed by #85

Comments

@samrensenhouse
Copy link

Describe the bug
This pth file https://github.com/mhammond/pywin32/blob/main/pywin32.pth seems to break _handle_pth_file. It errors out when checking if the directory exists.

  File "...\__pypackages__\3.8\lib\mkdocstrings_handlers\python\handler.py", line 182, in collect
    loader = GriffeLoader(
  File "...\__pypackages__\3.8\lib\griffe\loader.py", line 95, in __init__
    self.finder: ModuleFinder = ModuleFinder(search_paths)
  File "...\__pypackages__\3.8\lib\griffe\finder.py", line 59, in __init__
    self._extend_from_pth_files()
  File "...\__pypackages__\3.8\lib\griffe\finder.py", line 239, in _extend_from_pth_files
    self._append_search_path(_handle_pth_file(item))
  File "...\__pypackages__\3.8\lib\griffe\finder.py", line 282, in _handle_pth_file
    if added_dir.exists():
  File "...\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1383, in exists
    self.stat()
  File "...\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1189, in stat
    return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: "# .pth file for the PyWin32 extensions\nwin32\nwin32\\lib\nPythonwin\n# And some hackery to deal with environments where the post_install script\n# isn't run.\nimport pywin32_bootstrap"

To Reproduce
Steps to reproduce the behavior:

  1. Install pywin32 package
  2. Run griffe through mkdocstrings

mkdocs.yml

site_name: "Example"

nav:
- Home: index.md

plugins:
- mkdocstrings:
    default_handler: python

index.md

::: src.some_file.SomeClass

Expected behavior
Regardless of whether pywin32 is installed I would expect griffe to run successfully. If I uninstall the package, it works successfully.

System (please complete the following information):

  • griffe version: 0.20.0
  • Python version: 3.8
  • OS: Windows
GabDug added a commit to GabDug/griffe that referenced this issue Jun 9, 2022
Fixes mkdocstrings#84

Very naive implementation for single-line comments
@pawamoy
Copy link
Member

pawamoy commented Jun 10, 2022

Thanks for the report! I see there's already a PR, will review it now 🙂

pawamoy pushed a commit that referenced this issue Jun 14, 2022
Issue #84: #84
PR #85: #85
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
@sanand0
Copy link

sanand0 commented Jun 19, 2022

I'm facing this issue at the moment. Thrilled to see this fix! I'd be grateful for a release on pypi 🙏

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 a pull request may close this issue.

3 participants