Skip to content

Fix TypeError when formatting with black 22.1.0+#30

Merged
haplo merged 1 commit into
python-lsp:masterfrom
wlcx:fix-black-22.1.0
Jan 30, 2022
Merged

Fix TypeError when formatting with black 22.1.0+#30
haplo merged 1 commit into
python-lsp:masterfrom
wlcx:fix-black-22.1.0

Conversation

@wlcx

@wlcx wlcx commented Jan 30, 2022

Copy link
Copy Markdown
Contributor

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

@ccordoba12 ccordoba12 left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@haplo

haplo commented Jan 30, 2022

Copy link
Copy Markdown
Collaborator

@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

wlcx commented Jan 30, 2022

Copy link
Copy Markdown
Contributor Author

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

@wlcx

wlcx commented Jan 30, 2022

Copy link
Copy Markdown
Contributor Author

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

@haplo

haplo commented Jan 30, 2022

Copy link
Copy Markdown
Collaborator

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

haplo commented Jan 30, 2022

Copy link
Copy Markdown
Collaborator

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

wlcx commented Jan 30, 2022

Copy link
Copy Markdown
Contributor Author

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

@haplo haplo left a comment

Copy link
Copy Markdown
Collaborator

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

haplo commented Jan 30, 2022

Copy link
Copy Markdown
Collaborator

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

@wlcx

wlcx commented Jan 30, 2022

Copy link
Copy Markdown
Contributor Author

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

@ccordoba12

Copy link
Copy Markdown
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

3 participants