Skip to content

Conversation

@podhmo
Copy link

@podhmo podhmo commented Apr 20, 2021

supports #269

@codecov
Copy link

codecov bot commented Apr 20, 2021

Codecov Report

Merging #270 (083fc91) into master (c3a4c72) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #270   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          242       242           
  Lines         4508      4509    +1     
=========================================
+ Hits          4508      4509    +1     
Impacted Files Coverage Δ
typer/utils.py 100.00% <ø> (ø)
typer/models.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3a4c72...083fc91. Read the comment docs.

name: str,
default: Any = inspect.Parameter.empty,
annotation: Any = inspect.Parameter.empty,
kind: inspect._ParameterKind = inspect.Parameter.POSITIONAL_OR_KEYWORD,
Copy link
Author

Choose a reason for hiding this comment

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

accessing inspect._ParameterKind is ugly a bit, but the type name is _ParameterKind
https://github.com/python/typeshed/blob/a690a14c820238ca7a64cd502343d6b5a649e731/stdlib/inspect.pyi#L125-L134

elif param.default == Required or param.default == param.empty:
required = True
parameter_info = ArgumentInfo()
if param.kind == inspect.Parameter.KEYWORD_ONLY:
Copy link
Author

Choose a reason for hiding this comment

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

Where should I write the test?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, there would be a tutorial file in docs_src demonstrating the behavior. And then a test for that file in tests/test_tutorial/. Then reference the file in the markdown documentation with a brief explanation.

Sometimes there are tricky edge cases that don't fit into tutorials. In that case, you can add some tests in the top level of the tests/ directory.

@podhmo podhmo marked this pull request as ready for review April 20, 2021 12:36
@Afoucaul
Copy link

Afoucaul commented Aug 13, 2021

@podhmo do you need some help on this PR? I really feel like this feature would be game breaker!

@Afoucaul
Copy link

Afoucaul commented Sep 7, 2021

@tiangolo What is missing in this PR so that it can be accepted? How could I help making it complete?

@podhmo
Copy link
Author

podhmo commented Sep 8, 2021

Oh, sorry for late response, the missing part is tests.
this PR is work ( at least for me ) , but test code is missing.

Copy link
Contributor

@ryangalamb ryangalamb left a comment

Choose a reason for hiding this comment

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

As pointed out earlier, tests are the main thing blocking this right now.

FWIW, this is a breaking change (existing CLIs that use keyword-only arguments will change behavior), but I think this is useful enough to justify a breaking change.

Let me know if you have any more questions about how/where to add tests.

elif param.default == Required or param.default == param.empty:
required = True
parameter_info = ArgumentInfo()
if param.kind == inspect.Parameter.KEYWORD_ONLY:
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally, there would be a tutorial file in docs_src demonstrating the behavior. And then a test for that file in tests/test_tutorial/. Then reference the file in the markdown documentation with a brief explanation.

Sometimes there are tricky edge cases that don't fit into tutorials. In that case, you can add some tests in the top level of the tests/ directory.

@podhmo
Copy link
Author

podhmo commented Apr 27, 2023

Thank you for the comments, but sorry, I've lost the motivation.

So, feel free to reopen or reuse the code in new pull request.

@podhmo podhmo closed this Apr 27, 2023
@ryangalamb
Copy link
Contributor

Sounds good, thanks for responding and sharing your code/time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants