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

Add type hints for ._app #359

Merged
merged 9 commits into from
Jul 21, 2020
Merged

Add type hints for ._app #359

merged 9 commits into from
Jul 21, 2020

Conversation

wsanchez
Copy link
Member

@wsanchez wsanchez commented Jun 9, 2020

Type hints for ._app.py

@wsanchez wsanchez requested a review from a team as a code owner June 9, 2020 21:22
@wsanchez wsanchez self-assigned this Jun 9, 2020
@wsanchez wsanchez changed the title Type hints for ._app Add type hints for ._app Jun 9, 2020
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #359 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #359   +/-   ##
=======================================
  Coverage   98.35%   98.36%           
=======================================
  Files          46       46           
  Lines        3892     3906   +14     
  Branches      256      256           
=======================================
+ Hits         3828     3842   +14     
  Misses         46       46           
  Partials       18       18           
Impacted Files Coverage Δ
src/klein/__init__.py 100.00% <100.00%> (ø)
src/klein/_app.py 100.00% <100.00%> (ø)
src/klein/test/test_resource.py 97.14% <100.00%> (+<0.01%) ⬆️

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 a3f6446...4798fdd. Read the comment docs.

@twm
Copy link
Contributor

twm commented Jul 15, 2020

@wsanchez It looks there aren't changes here anymore?

@wsanchez
Copy link
Member Author

@twm Well that's surprising…

@wsanchez
Copy link
Member Author

@twm: fixed

Copy link
Member

@glyph glyph left a comment

Choose a reason for hiding this comment

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

Thanks for the additional types!

  1. On the KleinRequest thing, please just file a separate issue to follow up on that so we don't forget; we really don't need to block on it.
  2. On the cast thing, I do feel like anywhere we have a type: ignore or a cast we should really include a comment explaining in English why we know it's safe, but don't feel like you have to block on the refactoring; just add the comment in both spots or add one comment pointing at the other if refactoring them is at all tricky.

Thanks for continuing to improve Klein's type discipline!

@@ -20,6 +31,9 @@

__all__ = (
"Klein",
"KleinErrorHandler",
Copy link
Member

Choose a reason for hiding this comment

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

Great to have some sensible public names for these!

):
# type: (...) -> Text
assert self.mapper is not None
return cast(
Copy link
Member

Choose a reason for hiding this comment

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

Why do we know for sure that this cast is valid?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally, Werkzeug will add types in the future.

In the meantime, I guess we hope the docs showing strings in all examples means it's returning strings all the time

Copy link
Member

Choose a reason for hiding this comment

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

Oh wait is this a cast to narrow? I thought it was a cast away from some other type, not Any

Copy link
Member

Choose a reason for hiding this comment

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

If it's just to narrow I'd say you could stkip it, since the -> Text will fix it anyway?

@wsanchez wsanchez merged commit 5aa6363 into master Jul 21, 2020
@wsanchez wsanchez deleted the mypy-app branch July 21, 2020 18:18
@wsanchez wsanchez mentioned this pull request Jul 21, 2020
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.

3 participants