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

ament_black cannot parse python 3.10 code #4

Open
LeviTranstrum opened this issue Mar 2, 2023 · 0 comments
Open

ament_black cannot parse python 3.10 code #4

LeviTranstrum opened this issue Mar 2, 2023 · 0 comments

Comments

@LeviTranstrum
Copy link

Hello, I am implementing ament_black as a pytest to run on all my ROS packages when colcon test is called. It works wonderfully well - except for one package which contains a file with python 3.10 code. This file causes ament_black to fail with the message, "The invocation of 'black' failed with error code 123".

When I run black on the same file, its output is a little more descriptive:

error: cannot format driver.py: Cannot parse: 189:18: match request.operation: Consider using --target-version py310 to parse Python 3.10 code. Oh no! 💥 💔 💥 1 file failed to reformat.

The suggested --target-version flag works with black, but ament_black accepts no such flag. I've dug through your documentation and code and can't seem to find any option to configure the target version.

Your ament_black/main.py seems to suggest that a --config flag can be passed in to set the path to a config file, however, ament_black doesn't seem to accept this flag.

my test_black.py configuration is below:

`from ament_black.main import main

def test_black():
rc = main(
argv=[
"--xunit-file",
"black.xunit.xml",
"."
]
)
assert rc == 0, "black failed with error code %d" % rc`

Is there a way to configure ament_black to understand this file, or at least skip it (without having to manually set the path to every other .py file in the package)?

Any help would be appreciated - I'm new at this, but ament_black has already been incredibly useful especially alongside other ament_lint packages. Thank you!

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

No branches or pull requests

1 participant