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

Update click to 8 #432

Closed
wants to merge 3 commits into from
Closed

Conversation

DavidOliver
Copy link
Contributor

Warning: I don't know what I'm doing; I don't usually use Python and this is my first time with Watson's code, so this pull request should be treated with caution. But hopefully it can at least act as the start of a fix for use of click v8.

The cause of #430 seems to be this (click v8 changes):

TypeError is raised when parameter with multiple=True or nargs > 1 has non-iterable default. #1749

'Multiple options' at click documentation.

I remove multiple=True from several click options, which I don't believe are intended to be specified at the command line more than once as they seem to be flags rather than options which take (multiple) values.

I believe I've successfully run Watson's tests, which all seem to be passing.

By the way, will a new release of Watson be prepared soon, either with the temporary fix of specifying v7 of click or this fix? I ask as I'm currently working on my system config. :)

@jmaupetit
Copy link
Member

Wow this is huge. Thanks 🙏 We'll look into this soon.

requirements.txt Outdated
@@ -1,5 +1,5 @@
arrow>=1.0.0
click>=7.0,<8.0
click>=8.0,<9.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should explicitly forbid 9.0, we don't know if that will be a breaking change for us yet. We usually try to avoid pinning versions if we can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I restricted to 8 partly because it was a "MAJOR" semver version change (7 to 8) that broke Watson. I'm not familiar with either project, but shouldn't major releases of dependencies only be (explicitly) updated to once they've been tested due to the likelihood of breaking changes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a long debate in the Python community :) . So far my opinion is to allow any version of a dependency as long as you don't know for sure that you're not compatible with it. This is less of an issue if you isolate the dependencies of each Python project you're using, but if you're not doing it things can get messy pretty quickly if everybody is asking for specific versions of a package for no proper reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh - interesting! Seems like asking for trouble to me. :D Will you remove the <9 requirement or should I?

Copy link
Member

Choose a reason for hiding this comment

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

Hi David! Can you fix this, and then I'll merge your work and release it. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Done.

Copy link
Collaborator

@k4nar k4nar left a comment

Choose a reason for hiding this comment

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

Indeed I don't think those should have been marked as "multiple", this was probably a bad copy/paste in the first place 😄 .

This looks to me, except for the small comment about the pinned version 👍 . Thank you very much!

@mizhozan
Copy link

mizhozan commented May 26, 2021

I'm not pro Python user and don't much about test suits, but my test with this pr on my local computer works fine plus I did a simple pytest and there was 250 passed, 14 warning, 91 errors as following gist.

I simply did a gh pr checkout 432 and then pip install and check watson which works just fine. For the test I just did pytest from the command line, if it's supposed (didn't see the documentation on test).

@DavidOliver
Copy link
Contributor Author

@mizhozan, I also had those fixture-related failures. The solution seemed to be install the dev requirements from requirements-dev.txt. (See the varying mock versions depending on the version of setuptools you have.)

@mizhozan
Copy link

mizhozan commented May 27, 2021

@DavidOliver Thanks a lot, now the test runs perfectly with 341 passes and 14 warnings according to this gist.

@mizhozan, I also had those fixture-related failures. The solution seemed to be install the dev requirements from requirements-dev.txt. (See the varying mock versions depending on the version of setuptools you have.)

As requested by maintainers.
@DavidOliver
Copy link
Contributor Author

DavidOliver commented May 27, 2021

@mizhozan Thanks. I think I managed to confuse myself regarding the versions of packages I had installed. I've just (re-?)re-installed click (8.0.1), and now I also have the deprection warnings when running the tests.

@jmaupetit Can you hold off on merging, please? I'll see if I can get rid of the deprecation warnings.

@DavidOliver
Copy link
Contributor Author

DavidOliver commented May 27, 2021

The deprecation warnings in the tests are now gone (see last commit), but I'm out of my depth here and can't know whether or not more needs to be done to properly update to click 8.

From the changelog:

Redesign the shell completion system. #1484, #1622

Support Bash >= 4.4, Zsh, and Fish, with the ability for extensions to add support for other shells.

Allow commands, groups, parameters, and types to override their completions suggestions.

Groups complete the names commands were registered with, which can differ from the name they were created with.

The autocompletion parameter for options and arguments is renamed to shell_complete. The function must take ctx, param, incomplete, must do matching rather than return all values, and must return a list of strings or a list of CompletionItem. The old name and behavior is deprecated and will be removed in 8.1.

The env var values used to start completion have changed order. The shell now comes first, such as {shell}source rather than source{shell}, and is always required.

Regarding shell_complete, it looks like the args taken may not need updating, but I don't know about "matching rather than return all values" and the return values.

Regarding env var values to start completion, I've searched for source_ in Watson's code and found source_zsh in create-completion-script.sh. I think this is where I bow out and leave things for others with more knowledge and understanding of Watson and Python. Thanks!

SuperSandro2000 pushed a commit to NixOS/nixpkgs that referenced this pull request Jul 10, 2021
pythonPackages brings click 8. Unfortunately, watson is not ready to
consume this library yet. Fix by explicitly pulling in click 7 as
dependency. See these upstream discussions:

TailorDev/Watson#430
TailorDev/Watson#432
@MinchinWeb
Copy link
Contributor

Ran into this issue today. Would love to see this merged in.

@Xiretza
Copy link

Xiretza commented May 15, 2022

It's been almost a year, what's the status on this?

@jmaupetit
Copy link
Member

Rebased and merged in #471

@jmaupetit jmaupetit closed this May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants