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

config options handle spaces and newlines #93

Merged
merged 4 commits into from
Dec 31, 2022

Conversation

jakkdl
Copy link
Member

@jakkdl jakkdl commented Dec 29, 2022

fix #84 and #89
--startable-in-context-manager and --trio200-blocking-calls now handle spaces and newlines.

… and --trio200-blocking-calls now handle spaces and newlines
Comment on lines -93 to +96
for arg in reg_match.group().split(" "):
if arg.strip():
parsed_args.append(arg.strip())
parsed_args.append(reg_match.group().strip())
Copy link
Member Author

Choose a reason for hiding this comment

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

Changed this to handle spaces in a command line arg - this means that the name ARGS is misleading but that is renamed in #91 (rip me bundling changes again).
This leads to some minor merge conflicts, but I'll likely rebase #91 on top of this one to fix those.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good - I'll next have internet around Jan 9th, so don't panic if review is a bit delayed.

Copy link
Member Author

Choose a reason for hiding this comment

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

gtk, I'll rebase and fix merge conflicts in it. May also split it up if I start messing with stuff in other PR's that might lead to conflicts.

Comment on lines +476 to +498
def test_200_from_config_flake8_internals(
tmp_path: Path, capsys: pytest.CaptureFixture[str]
):
# abuse flake8 internals to avoid having to use subprocess
# which breaks breakpoints and hinders debugging
# TODO: fixture (?) to change working directory

err_msg = _test_trio200_from_config_common(tmp_path)
# replace ./ with tmp_path/
err_msg = str(tmp_path) + err_msg[1:]

from flake8.main.cli import main

main(
argv=[
str(tmp_path / "example.py"),
"--append-config",
str(tmp_path / ".flake8"),
]
)
out, err = capsys.readouterr()
assert not err
assert err_msg == out
Copy link
Member Author

Choose a reason for hiding this comment

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

almost funny after the fact how massively the subprocess call broke my debugging workflow and made finding out why tests broke take ages (a trailing comma in the list of config options).

I broke this out as a separate test in case flake8 internals break, but feels like there should be a cleaner solution that doesn't rely on any internal structure at all and just emulates calling it with python -m. Something like runpy.run_module but with also setting sys.argv and working dir. I didn't find anything that didn't require writing a bunch of extra code, but if you have anything I'd love to hear of it.

Copy link
Member

Choose a reason for hiding this comment

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

No specific advice sorry, but I appreciate having this test broken out!

Comment on lines +476 to +498
def test_200_from_config_flake8_internals(
tmp_path: Path, capsys: pytest.CaptureFixture[str]
):
# abuse flake8 internals to avoid having to use subprocess
# which breaks breakpoints and hinders debugging
# TODO: fixture (?) to change working directory

err_msg = _test_trio200_from_config_common(tmp_path)
# replace ./ with tmp_path/
err_msg = str(tmp_path) + err_msg[1:]

from flake8.main.cli import main

main(
argv=[
str(tmp_path / "example.py"),
"--append-config",
str(tmp_path / ".flake8"),
]
)
out, err = capsys.readouterr()
assert not err
assert err_msg == out
Copy link
Member

Choose a reason for hiding this comment

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

No specific advice sorry, but I appreciate having this test broken out!

tests/test_flake8_trio.py Outdated Show resolved Hide resolved
Comment on lines -93 to +96
for arg in reg_match.group().split(" "):
if arg.strip():
parsed_args.append(arg.strip())
parsed_args.append(reg_match.group().strip())
Copy link
Member

Choose a reason for hiding this comment

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

Sounds good - I'll next have internet around Jan 9th, so don't panic if review is a bit delayed.

@Zac-HD Zac-HD merged commit 115eb5e into python-trio:main Dec 31, 2022
@jakkdl jakkdl deleted the config_parsing_type branch December 31, 2022 13:06
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.

trio200-blocking-calls = is loaded but not parsed from a config file
2 participants