Repository navigation
fix(https): don't pass None CORS options to flask-cors; fix ruff PLR0917 - #336
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates CORS configuration handling in https_fn.py to dynamically build arguments, refines a regex pattern type annotation in options.py, and adds PLR0917 to the global ignore list in pyproject.toml. The review feedback recommends avoiding the global suppression of PLR0917 by using local suppression instead, and suggests refactoring the CORS dictionary construction to maintain type safety without resorting to _typing.Any.
shettyvarun268
marked this pull request as ready for review
November 10, 2026 21:13
wandamora
approved these changes
Nov 10, 2026
wandamora
left a comment
There was a problem hiding this comment.
A few nits, but overall LGTM. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix
on_requestCORS handling (https_fn.py,options.py):https_fn.on_requestalways passedmethods=options.cors.cors_methodsandorigins=options.cors.cors_originstoflask_cors.cross_origin(), even when either field wasNone.flask-corsmerges passed keyword arguments into its defaults viaoptions.update(...), passingNoneoverwrote the default value instead of falling back to it—crashing requests at runtime onflask-cors3.0.10through6.0.1when only one field ofCorsOptionswas set, and failing to emit CORS headers onflask-cors 6.0.5(as well as failingmypyagainstflask-cors 6.0.5'sCrossOriginOptionsInputTypedDict).on_requestto omit unsetCorsOptionsfields so they fall back toflask-corsdefaults ("*"for origins and all standard HTTP methods formethods), matchingon_call's behavior. PassingCorsOptions()with both fields unset now enables default permissive CORS headers across all origins and methods.CorsOptions.cors_originstype annotation from_re.Patternto_re.Pattern[str]and documented the default behavior when fields are left unset.main(and also unblocks theflask-cors 6.0.5upgrade in chore(deps): bump the version-minor-and-patch group across 1 directory with 14 updates #335).Ruff
PLR0917(dataconnect_fn.py):# noqa: PLR0917suppression on_dataconnect_endpoint_handlerindataconnect_fn.pyfor compatibility withruff 0.17.x(chore(deps): bump the version-minor-and-patch group across 1 directory with 14 updates #335).Testing
test_on_request_cors_options_branchesintests/test_https_fn.pytesting preflightOPTIONSrequests and assertingAccess-Control-Allow-OriginandAccess-Control-Allow-Methodsheaders across all 4CorsOptionscombinations plus a non-matching origin case.ruff check .,ruff format --check .,mypy ., andpytestall pass.