Skip to content

Conversation

@KangarooKoala
Copy link
Contributor

@KangarooKoala KangarooKoala commented Nov 28, 2025

This makes the requires clause parsing more accurate to the C++ standard. Notably, this allows having operators on parenthesized expressions. (Previously, something like requires (mp::m == Distance) || (mp::rad == Distance) would fail because the parser would only consume the first parenthesized expression, leaving || (mp::rad == Distance) to be unsuccessfully parsed as part of the declaration.)

Relevant pages:

The parenthesized parameter list is optional in a requires expression (See https://en.cppreference.com/w/cpp/language/requires.html), but for now I left it as mandatory. I could make that optional too if you want, though.

Also, what should be done for tests? I'm having trouble building locally (running uvx --from build pyproject-build --installer uv emits Error: You need to create a tag for this repo to use the builder), which appears to be necessary to run the tests. I also don't know if we want to add tests (and if so, where).

@virtuald
Copy link
Member

If you find an bug, we encourage you to submit a pull request! New changes will only be accepted if there are tests to cover the change you made (and if they don’t break existing tests).

In the tests directory, every test is generated via python -m cxxheaderparser.gentest. It takes a header file as an input, and prints out the testcase. Take the cases that don't currently work, put them in the header, and generate test cases.

I think uvx doesn't like my custom setuptools stuff. Just comment out the version stuff at the beginning of setup.py and it'll probably be happier. I've been meaning to migrate over to hatchling, so maybe I should do that.

I usually just do pip install -e . in the repository, followed by pip install pytest. Then you can run the tests using python -m pytest tests.

@virtuald
Copy link
Member

If you rebase on main, I migrated to hatchling. I haven't tested it, but I bet that uvx will be happier with that.

@KangarooKoala KangarooKoala force-pushed the better-requires-clauses branch from a6e171e to 0b3482f Compare November 28, 2025 22:07
@KangarooKoala
Copy link
Contributor Author

Thanks, rebasing on main fixed the uvx issues!

Copy link
Member

@virtuald virtuald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks simpler, thanks. One potential improvement?

@KangarooKoala KangarooKoala force-pushed the better-requires-clauses branch from 0b3482f to dc63715 Compare November 29, 2025 19:10
@virtuald virtuald merged commit 3abac6d into robotpy:main Nov 29, 2025
33 checks passed
@virtuald
Copy link
Member

Thanks!

@KangarooKoala KangarooKoala deleted the better-requires-clauses branch November 29, 2025 23:40
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