Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds full type annotations, with a strict config.
py.typed
file is added, so these annotations will be preferred over typeshed. Notes on some issues discovered / future work:Command.name
,Parameter.name
, etc. can all beNone
, but this makes the typing more complex than it has to be.name
can beNone
as long as it's provided when usingGroup.add_command
. The test runner will setname
to"root"
if the entry point doesn't have a name. I would deprecate not passing a name (it's only used this way in a few tests, it's already impossible when using the decorators).name
can beNone
only ifexpose_value
is disabled. Behind the scenes, the values are still recorded by the parser, but they're all overwrite theNone
key, which makes the dict type more annoying since you either have to ignore that the key isOptional[str]
or put extra casts/asserts all over the place since the code never actually accesses that key. I would change this to not record the value at all if it's not exposed.WindowsChunkedWriter
was only used for a Windows 7 / Python 2 compat, and is no longer needed.get_strerror
can be removed,OSError
always hasstrerror
and it's only called onOSError
.io
base classes, and so they need to becast()
all over.str
orbytes
explicitly.ParamType
could be generic so thatconvert
returns the expected type. This would also cut down on a lot of ignores on the number mixins.ProgressBar
could be generic so that it yields the expected type.ctx
to be optional, with a comment "for advanced use cases", but none of those use cases are suggested or tested, and the module is intended to be internal.**kwargs
. This would make IDE completion a lot better.invoke
andforward
.