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

mypy - Argument "api_gateway_base_path" to "Mangum" has incompatible type "str"; expected "Dict[str, Any]" #220

Merged
merged 11 commits into from
Jan 22, 2022

Conversation

relsunkaev
Copy link
Contributor

@relsunkaev relsunkaev commented Jan 11, 2022

  • Removed handler_kwargs from adapter and handler constructors in favor of an explicit api_gateway_base_path parameter (the only parameter handler_kwargs could have)
  • Removed unnecessary ContextManager typing on lifespan_cycle in adapter.py
  • Changed BaseRequest.scope to a property (formerly a function) for consistency with child classes
  • Scope, being a MutableMapping technically has no .copy() as part of its protocol (collections generally don't). Using copy.copy() in protocols.websockets.run() to reflect that
  • Additional typing

Closes #201

Ramazan Elsunkaev and others added 2 commits January 10, 2022 18:52
…anged `BaseRequest.scope` to a property (formerly a method) for consistency with child classes;
@jordaneremieff
Copy link
Collaborator

jordaneremieff commented Jan 20, 2022

Thanks @relsunkaev, I think this is good to merge. Before I do, I wanted to see if you might also remove the handler_kwargs and kwargs included in the handler class constructors? Seems like these aren't used anywhere.

If you're not sure about what I mean about the kwargs then I can alternatively just merge this and remove those later.

@relsunkaev
Copy link
Contributor Author

Yeah, I noticed the same thing but didn't look further into it since I didn't know if there was something planned for that. I'll add it to the PR.

@jordaneremieff
Copy link
Collaborator

@relsunkaev thanks. I added a comment to the (now closed) issue here discussing the kwargs validation more generally.

There is likely some more work to be done beyond just removing handler_kwargs and kwargs, but that'd be outside of the scope of this PR because we'd be committing to handling all existing and potential specific handler parameters in a single, consistent way going forward.

`api_gateway_base_path` is now an explict param;
Fixed two exception entries on lifespan config;
Added test for default `api_gateway_base_path` value;
@relsunkaev
Copy link
Contributor Author

Just updated my PR with the changes.

Ramazan Elsunkaev added 5 commits January 21, 2022 13:09
Created `QueryParams` TypeAlias in `types.py`;
`api_gateway_base_path` is now a positional arg in handlers;
Fixed tests to reflect the above;
Made imports consistent to use `from`;
Cleaned up some code to make Pylance happy;
Fixed setting InitVar in `WebSocket`;
@jordaneremieff
Copy link
Collaborator

@relsunkaev looks good, thanks!

@jordaneremieff jordaneremieff merged commit fad70a2 into Kludex:main Jan 22, 2022
khamaileon pushed a commit to khamaileon/mangum that referenced this pull request Jan 13, 2024
…#220)

* Fixed typing in adapter.py; Added more explicit types some places; Changed `BaseRequest.scope` to a property (formerly a method) for consistency with child classes;

* Removed `handler_kwargs`;
`api_gateway_base_path` is now an explict param;
Fixed two exception entries on lifespan config;
Added test for default `api_gateway_base_path` value;

* Fixed `AwsApiGateway` missing default for `api_gateway_base_path`;

* Added `api_gateway_base_path` param in `test_abstract_handler`;

* Removed `Optional` import from `abstract_handler`;

* Removed class attributes from `Mangum`;
Created `QueryParams` TypeAlias in `types.py`;
`api_gateway_base_path` is now a positional arg in handlers;
Fixed tests to reflect the above;
Made imports consistent to use `from`;
Cleaned up some code to make Pylance happy;
Fixed setting InitVar in `WebSocket`;

* Fixed linting error;

* Fixed coverage;

* Removed unused import;

Co-authored-by: Ramazan Elsunkaev <ramazan@up-linq.com>
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.

mypy - Argument "api_gateway_base_path" to "Mangum" has incompatible type "str"; expected "Dict[str, Any]"
2 participants