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

feat: type more falcon modules #2171

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open

Conversation

copalco
Copy link
Contributor

@copalco copalco commented Aug 22, 2023

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.

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst. (Run towncrier --draft to ensure it renders correctly.)

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
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (52db96d) 100.00% compared to head (cf3fce0) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2171   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           62        62           
  Lines         6871      6930   +59     
  Branches      1098      1098           
=========================================
+ Hits          6871      6930   +59     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@CaselIT CaselIT left a comment

Choose a reason for hiding this comment

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

Great work.

  • "from future annotation" is missing from a few modules
  • in general I'm not a fan of the type alias union that include None, like RawHeaders for example, since it's a bit strange to read headers: RawHeaders = None. That said it's my preference, as they are it's also ok
  • i'm not convinced we need the new modules that were added, it seems that we could just use the existing typing one. But I think it's better to wait the input of @vytas7 for this one

.coveragerc Outdated Show resolved Hide resolved
falcon/http_status.py Outdated Show resolved Hide resolved
falcon/link.py Outdated Show resolved Hide resolved
falcon/typing.py Show resolved Hide resolved
falcon/typing_http_data.py Outdated Show resolved Hide resolved
falcon/vendor/mimeparse/mimeparse.py Outdated Show resolved Hide resolved
falcon/middleware.py Outdated Show resolved Hide resolved
falcon/media_serializer.py Outdated Show resolved Hide resolved
falcon/errors.py Outdated Show resolved Hide resolved
falcon/errors.py Show resolved Hide resolved
Copy link
Member

@CaselIT CaselIT 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 update, I've repried to the open messages.

I'll try taking a better look locally to se if we can avoid some of the circular imports

@CaselIT CaselIT requested a review from vytas7 August 28, 2023 19:52
@CaselIT
Copy link
Member

CaselIT commented Aug 30, 2023

Thanks @copalco for the update, I'll try taking a look by the weekend!

Copy link
Member

@CaselIT CaselIT 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 updates. In general this looks mostly ok.

While it works on definition when using future annotation, I'm not sure if it has unintended consequences at runtime for older python

falcon/request.py Outdated Show resolved Hide resolved
falcon/request.py Outdated Show resolved Hide resolved
@CaselIT
Copy link
Member

CaselIT commented Sep 9, 2023

I've pushed an update to avoid the imports in the functions, using if TYPE_CHECKING

Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

Looks great, it's a massive chunk of work (bar a couple of nitpicks)!

I'm just not 100% convinced by these new base classes inside typing.py 🤔 Do we really need these? It would be easier to get this review merged if it did not introduce any changes to the codebase's behaviour/performance (which in turn needs more extensive testing), just annotations.
Or maybe we could split these into a separate PR?

falcon/response.py Outdated Show resolved Hide resolved
falcon/media/handlers.py Outdated Show resolved Hide resolved
falcon/inspect.py Outdated Show resolved Hide resolved
@vytas7 vytas7 changed the title type falcon modules feat: type more falcon modules Oct 15, 2023
Copy link
Member

@kgriffs kgriffs 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 your help on this! Retrofitting type hints is a lot of work and we really appreciate it. I still need to finish reviewing several of the modules, but wanted to share my comments so far to get you unblocked.

falcon/asgi_spec.py Show resolved Hide resolved
falcon/app_helpers.py Show resolved Hide resolved
falcon/errors.py Outdated Show resolved Hide resolved
falcon/typing.py Show resolved Hide resolved
falcon/hooks.py Outdated Show resolved Hide resolved
falcon/hooks.py Outdated Show resolved Hide resolved
falcon/hooks.py Outdated Show resolved Hide resolved
falcon/hooks.py Outdated Show resolved Hide resolved
falcon/hooks.py Outdated Show resolved Hide resolved
falcon/hooks.py Outdated Show resolved Hide resolved
@CaselIT
Copy link
Member

CaselIT commented Oct 16, 2023

@copalco let us know if you plan on continuing this or if we should take this over the finishing lie. In any case thanks a lot for the effort on this!

@copalco
Copy link
Contributor Author

copalco commented Oct 16, 2023

@copalco let us know if you plan on continuing this or if we should take this over the finishing lie. In any case thanks a lot for the effort on this!

Sure I can continue. Also I don't mind if you will just propose the actual change as a comment.

CaselIT
CaselIT previously approved these changes Nov 5, 2023
Copy link
Member

@CaselIT CaselIT 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 updating it

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.

None yet

4 participants