Skip to content

Conversation

@niooss-ledger
Copy link
Contributor

For reviewers

  • I did not use AI
  • I used AI and thorougly reviewed every code/docs change

Description of the change

Hello,

A space was missing between the value and for. For example,

import tempfile
import sys
import griffe

with tempfile.TemporaryDirectory() as tmp:
    sys.path.insert(0, tmp)
    with open(f"{tmp}/test_for_griffe.py", "x") as f:
        print("A = {key: value for key, value in []}", file=f)

    module = griffe.load("test_for_griffe")
    print(module.get_member("A").value)

displayed:

```python
{key: valuefor (key, value) in []}

Add the missing space.

Relevant resources

I encountered an issue with mkdocstrings-python and reported it in mkdocstrings/python#311 . This Pull Request fixes a part of this issue: with it, random characters no longer appear (because they are used by mkdocstrings-python to track cross-references). But there are still rendering issues, due to some code present in mkdocstrings-python (not in griffe).

niooss-ledger and others added 2 commits October 9, 2025 11:37
A space was missing between the value and `for`. For example,

    import tempfile
    import sys
    import griffe

    with tempfile.TemporaryDirectory() as tmp:
        sys.path.insert(0, tmp)
        with open(f"{tmp}/test_for_griffe.py", "x") as f:
            print("A = {key: value for key, value in []}", file=f)

        module = griffe.load("test_for_griffe")
        print(module.get_member("A").value)

displayed:

    {key: valuefor (key, value) in []}

Add the missing space.

For more context, see mkdocstrings/python#311
@pawamoy
Copy link
Member

pawamoy commented Oct 9, 2025

Awesome, thanks a lot @niooss-ledger! I just added a test that is expected to fail because for now parentheses are still added around the tuple. I have a fix for that too and will push it once this PR is merged 🙂

@pawamoy pawamoy merged commit 3a6dc36 into mkdocstrings:main Oct 9, 2025
1 check passed
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.

2 participants