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

Fix TypeError when formatting with black 22.1.0+ #30

Merged
merged 1 commit into from
Jan 30, 2022
Merged

Fix TypeError when formatting with black 22.1.0+ #30

merged 1 commit into from
Jan 30, 2022

Conversation

wlcx
Copy link
Contributor

@wlcx wlcx commented Jan 30, 2022

Resolve an TypeError issue caused by the return type of find_project_root changing in black 22.1.0.

Closes #29

@ccordoba12 ccordoba12 added this to the v1.1.0 milestone Jan 30, 2022
Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

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

Hey @wlcx, thanks a lot for your help with this! Your fix is correct, but you also need to fix our tests because Black 22.1 dropped Python 2 support.

For that, please go to

and change it for

target-version = ['py39']

Then here

def test_load_config_target_version():
config = load_config(str(fixtures_dir / "target_version" / "example.py"))
assert config["target_version"] == {black.TargetVersion.PY27}

please change PY27 to PY39.

That should be enough.

@ccordoba12
Copy link
Member

@haplo, I think this requires an urgent 1.1.0 release.

@haplo
Copy link
Collaborator

haplo commented Jan 30, 2022

@haplo, I think this requires an urgent 1.1.0 release.

Agreed. I'm reproducing the error and validating this fix.

@wlcx Will you be able to implement @ccordoba12's suggestion to fix the test suite? I can help with it if necessary, just let me know.

@wlcx
Copy link
Contributor Author

wlcx commented Jan 30, 2022

Damn that was quick! On it now, also wrangling mypy errors.

@wlcx
Copy link
Contributor Author

wlcx commented Jan 30, 2022

Do we need to retain backwards compatibility with prior black versions or can we require 22.1.0 as a minimum?

@haplo
Copy link
Collaborator

haplo commented Jan 30, 2022

Do we need to retain backwards compatibility with prior black versions or can we require 22.1.0 as a minimum?

I would like to retain backwards-compatibility, some users might not be able to upgrade for some reason. Is something in particular making it difficult?

Resolve an TypeError issue caused by the return type of
`find_project_root` changing in black 22.1.0.
@haplo
Copy link
Collaborator

haplo commented Jan 30, 2022

I would like to retain backwards-compatibility

This being said, I do believe python-lsp-black will only officially support the latest black version, so I will be adding a note about that in the README.

@wlcx
Copy link
Contributor Author

wlcx commented Jan 30, 2022

Ok, think we're good to go, just need that first-time-contributor workflow approval

Copy link
Collaborator

@haplo haplo left a comment

Choose a reason for hiding this comment

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

Tested fix with old and new black versions, both work. 👍

@haplo haplo merged commit c1be01c into python-lsp:master Jan 30, 2022
@haplo
Copy link
Collaborator

haplo commented Jan 30, 2022

Thank you for your help @wlcx, I will prepare a release immediately. :shipit:

@wlcx
Copy link
Contributor Author

wlcx commented Jan 30, 2022

No worries, thanks for such an awesome and speedy response both!

@ccordoba12
Copy link
Member

Thanks @haplo for your help with this!

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.

TypeError when formatting with Black 22.1
3 participants