Skip to content

Fix return value and type signature of shell_completion.add_completion_class function#2421

Merged
saroad2 merged 9 commits intopallets:8.1.xfrom
alexreg:fix-add_completion_class
May 8, 2023
Merged

Fix return value and type signature of shell_completion.add_completion_class function#2421
saroad2 merged 9 commits intopallets:8.1.xfrom
alexreg:fix-add_completion_class

Conversation

@alexreg
Copy link
Contributor

@alexreg alexreg commented Dec 24, 2022

Decorators should return a possibly modfiied version of the original type. Hence, add_completion_class should return cls rather than merely None. This conforms to Python conventions, and allows type checking to work properly.

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

@alexreg alexreg force-pushed the fix-add_completion_class branch from 0131aeb to eda387a Compare December 24, 2022 18:12
@alexreg
Copy link
Contributor Author

alexreg commented Dec 24, 2022

Pre-commit check failures seem to concern pre-existing issues.

@alexreg
Copy link
Contributor Author

alexreg commented Jan 7, 2023

Hi @davidism. Is this okay for you?

@saroad2
Copy link
Contributor

saroad2 commented May 7, 2023

Hey @alexreg , thanks for the PR.

While this PR is pretty straight-forward, you didn't include any tests to verify it.
Can you add some tests to check that everything works smoothly?

@alexreg alexreg force-pushed the fix-add_completion_class branch from 5a890b2 to 2da801a Compare May 7, 2023 23:14
@alexreg alexreg force-pushed the fix-add_completion_class branch from bdc2ef5 to 4e88449 Compare May 7, 2023 23:18
@alexreg
Copy link
Contributor Author

alexreg commented May 7, 2023

@saroad2 Sure. I added a couple of tests for the return value.

Copy link
Contributor

@saroad2 saroad2 left a comment

Choose a reason for hiding this comment

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

Looks good.

I had one comment about the tests regarding the usage of _available_shells.clear(). If you have any questions about my comment, please feel free to ask.

@saroad2
Copy link
Contributor

saroad2 commented May 8, 2023

Hey @alexreg , thank you for responding to my review. I'm glad I was able to introduce you to new concepts.

I've added some small tweaks to your PR, mainly a small refactoring for the fixture, elaboration on the steps of the tests you wrote, and add one more test about using add_completion_class with the name parameter.

Happily merging the PR and hope to see your contributions again in the future!

@saroad2 saroad2 merged commit e002dbc into pallets:8.1.x May 8, 2023
@alexreg
Copy link
Contributor Author

alexreg commented May 8, 2023

@saroad2 Looks good, re the tests. I'm not sure why I treated the dict like a value type in the fixture, but glad you fixed that too... Cheers.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2023
@kdeldycke kdeldycke added this to the 8.1.4 milestone Aug 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants