Skip to content

Conversation

@leakec
Copy link
Contributor

@leakec leakec commented Nov 15, 2025

  • Similar to the sample_header_test, but this uses the full CLI rather than extracting via the Python API.
  • Also, adds a test where the header has spaces in the name.

@leakec
Copy link
Contributor Author

leakec commented Nov 15, 2025

Tagging @henryiii for review. This just adds a couple of unit tests that run the full CLI, since all the other unit tests use the Python API to generate the docstrings. These also test that filenames with spaces in them work (tests what #38 fixed).

@leakec
Copy link
Contributor Author

leakec commented Nov 15, 2025

@henryiii Looks great to me, thanks for the improved changes. Out of curiosity, how did you know to use resolve vs. absolute (did some research to find it was indeed undocumented before Python 3.11) in pathlib? Is this just something you knew from having run into it before?

@henryiii
Copy link
Collaborator

henryiii commented Nov 15, 2025

I think it was from type checkers originally not having absolute, so I then looked it up and found resolve was preferred (that was well before 3.11). DIR = Path(__file__).resolve().parent is now just an idiom everywhere. You probably don't need the resolve(), as by 3.9 it's really hard to get __file__ to be relative. It might be impossible for a module to have a relative path anymore (unless it's not on a file system, like if you put it into a .pyz, but then __file__ doesn't work at all, you have to use importlib.resources in that case).

@henryiii henryiii merged commit a26db74 into pybind:master Nov 15, 2025
8 checks passed
@henryiii
Copy link
Collaborator

Thanks!

@leakec
Copy link
Contributor Author

leakec commented Nov 15, 2025

I think it was from type checkers originally not having absolute, so I then looked it up and found resolve was preferred (that was well before 3.11). DIR = Path(__file__).resolve().parent is now just an idiom everywhere. You probably don't need the resolve(), as by 3.9 it's really hard to get __file__ to be relative. It might be impossible for a module (unless it's not on a file system, like if you put it into a .pyz, but then __file__ doesn't work at all, you have to use importlib.resources in that case).

Ahh gotcha, makes sense. Thanks!

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