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

Reformat a few test files #140

Merged
merged 1 commit into from
Jan 23, 2022
Merged

Conversation

AlexWaygood
Copy link
Collaborator

Looks like I missed several test files when reformatting the tests in #129. Not sure why.

Haven't changed the substance of any of the tests here, just making them more concise and more typesheddy.

@Akuli
Copy link
Collaborator

Akuli commented Jan 23, 2022

I like the new formatting :)

Can you intentionally mess up one of the test files to make sure that pre-commit will fix it?

@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jan 23, 2022

I like the new formatting :)

Can you intentionally mess up one of the test files to make sure that pre-commit will fix it?

It won't -- we're still not running black on the .pyi files :/

[tool.black]
force-exclude = ".*\\.pyi"

I tried doing so, but it's counter-productive -- you end up with crazy things like this in tests/attribute_annotations.pyi, for example, as a desperate attempt by black to fix line lengths:

-    field5 = 0  # type: int  # Y015 Attribute must not have a default value other than "..."
+    field5 = (
+        0
+    )  # type: int  # Y015 Attribute must not have a default value other than "..."

I prepared this PR manually because the formatting was annoying me :)

@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jan 23, 2022

We already checked that pre-commit will fix import problems using isort on the .pyi and .py files, though, and I also checked that pre-commit will use black to fix other problems in the .py files -- see #130.

@AlexWaygood
Copy link
Collaborator Author

Is it possible to set different config options for black in pyproject.toml for the .pyi files? If so, we could set max-line-length = 500 or something for the .pyi test files, and it wouldn't be nearly so problematic to run black on the test files.

@srittau srittau merged commit 6ab9bd0 into PyCQA:master Jan 23, 2022
@AlexWaygood AlexWaygood deleted the tests-formatting branch January 23, 2022 18:01
@JelleZijlstra
Copy link
Collaborator

Is it possible to set different config options for black in pyproject.toml for the .pyi files?

No, Black doesn't support using different formatting options for part of a project. psf/black#1370

@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jan 23, 2022

Is it possible to set different config options for black in pyproject.toml for the .pyi files?

No, Black doesn't support using different formatting options for part of a project. psf/black#1370

That's a shame 😕

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.

4 participants