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

Parameter typing improvements #2805

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Parameter typing improvements #2805

wants to merge 4 commits into from

Conversation

AndreasBackx
Copy link
Collaborator

@AndreasBackx AndreasBackx commented Nov 9, 2024

This removes all of the type: ignore mentions in Argument, its subclasses, and the exceptions module. To do so, the following is done:

  1. Parameter is now an abstract base class. This just clarifies it cannot be instantiated which was always the point.
  2. Parameter.name can no longer be None. It only ever is None when expose_value = False. Instead of having to deal with None and is None everywhere, let's just use "" instead of None when expose_value is False
  3. ctx in Parameter.get_error_hint can be None. It always has been like this, but wasn't explicit in typing. Better to be explicit than implicit.
  • Add tests that demonstrate the correct behavior of the change. Tests
    should fail without the change.
    • Parameter.name is an implementation detail, it's not in the documentation.
  • 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.


return value, args

def get_help_record(self, ctx: Context) -> tuple[str, str] | None:
pass
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Linter complains about not having an implementation when it's an abstract base class. Using return None makes it not do that.

@AndreasBackx AndreasBackx marked this pull request as ready for review November 9, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant