falconry / falcon

The no-magic web data plane API and microservices framework for Python developers, with a focus on reliability, correctness, and performance at scale.
https://falcon.readthedocs.io/en/stable/
Apache License 2.0
9.51k stars 937 forks source link

feat(typing): type util package #2170

Closed copalco closed 1 year ago

copalco commented 1 year ago

Summary of Changes

Replace this text with a high-level summary of the changes included in this PR.

Related Issues

Please reference here any issue #'s that are relevant to this PR, or simply enter "N/A" if this PR does not relate to any existing issues.

Pull Request Checklist

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once; it will save you a few review cycles!

If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing to do.

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

PR template inspired by the attrs project.

codecov[bot] commented 1 year ago

Codecov Report

Merging #2170 (8f3478a) into master (f00722a) will not change coverage. The diff coverage is 100.00%.

:exclamation: Current head 8f3478a differs from pull request most recent head a8b18a4. Consider uploading reports for the commit a8b18a4 to get more accurate results

@@            Coverage Diff            @@
##            master     #2170   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           62        62           
  Lines         6833      6875   +42     
  Branches      1098      1098           
=========================================
+ Hits          6833      6875   +42     
Files Changed Coverage Δ
falcon/util/__init__.py 100.00% <100.00%> (ø)
falcon/util/deprecation.py 100.00% <100.00%> (ø)
falcon/util/misc.py 100.00% <100.00%> (ø)
falcon/util/reader.py 100.00% <100.00%> (ø)
falcon/util/structures.py 100.00% <100.00%> (ø)
falcon/util/sync.py 100.00% <100.00%> (ø)
falcon/util/uri.py 100.00% <100.00%> (ø)
CaselIT commented 1 year ago

Also another question. Does it make sense to add future-annotation to all modules that have typing? Personally I think it makes sense, and it should also limit the performance impact of adding typing on the import of a module. @vytas7 do you have a preference here?

vytas7 commented 1 year ago

What do you mean by performance impact @CaselIT? Annotations shouldn't affect code perf once they are parsed... or do you mean import times?

And re future-annotations, if you mean from __future__ import annotations, I'm not very opinionated; but AFAICT I can only see the positives since we don't (ab)use annotations for anything else than providing type hints. So effectively we would need to import less stuff just for typing?

CaselIT commented 1 year ago

Yes I meant the import time of a module