fix(mypy): addresses lack of optional types#521
fix(mypy): addresses lack of optional types#521heitorlessa merged 10 commits intoaws-powertools:developfrom
Conversation
Resolve errors related to the "no_implicit_optional" flag in mypy.ini
|
@heitorlessa with |
Codecov Report
@@ Coverage Diff @@
## develop #521 +/- ##
========================================
Coverage 99.23% 99.23%
========================================
Files 113 113
Lines 4468 4468
Branches 243 243
========================================
Hits 4434 4434
Misses 22 22
Partials 12 12
Continue to review full report at Codecov.
|
`env` is actually a required value otherwise strtobool would fail
heitorlessa
left a comment
There was a problem hiding this comment.
only one question on whether Optional[Sequence] is the correct type for __build_config as opposed to Union[List, Tuple, None]
|
I've just tried fixing the Union[Tuple, List] with a Sequence and it worked w/ MyPy -- perhaps I have MyPy misconfigured in PyCharm? I'll look into other bug now then merge as-is if you're still seeing the issue. from typing import Any, Callable, Dict, List, Optional, Tuple, Union, Sequence
def __init__(
self,
service: Optional[str] = None,
disabled: Optional[bool] = None,
auto_patch: Optional[bool] = None,
patch_modules: Optional[Sequence[str]] = None,
provider: Optional[BaseProvider] = None,
):
def patch(self, modules: Optional[Sequence[str]] = None):
def __build_config(
self,
service: Optional[str] = None,
disabled: Optional[bool] = None,
auto_patch: Optional[bool] = None,
patch_modules: Optional[Sequence[str]] = None,
provider: Optional[BaseProvider] = None,
):I've also added the following modules to ignore their lack of typehints, which makes me wonder how reliable this is: https://pypi.org/project/mypy-boto3/ [mypy-boto3]
ignore_missing_imports = True
[mypy-boto3.dynamodb.conditions]
ignore_missing_imports = True
[mypy-botocore.config]
ignore_missing_imports = True
[mypy-botocore.exceptions]
ignore_missing_imports = True
[mypy-aws_xray_sdk.ext.aiohttp.client]
ignore_missing_imports = True |
|
@heitorlessa ok your suggestions work prefectly, i have pushed the latest |
* develop: chore(deps): bump boto3 from 1.18.0 to 1.18.1 (aws-powertools#528) fix(tracer): mypy generic to preserve decorated method signature (aws-powertools#529) fix(parser): Make ApiGateway version, authorizer fields optional (aws-powertools#532) fix(mypy): fixes to resolve no implicit optional errors (aws-powertools#521) chore(deps): bump boto3 from 1.17.110 to 1.18.0 (aws-powertools#527) feat(feat-toggle): New simple feature toggles rule engine (WIP) (aws-powertools#494) chore(deps-dev): bump mkdocs-material from 7.1.9 to 7.1.10 (aws-powertools#522) chore(deps): bump boto3 from 1.17.102 to 1.17.110 (aws-powertools#523) chore(deps-dev): bump isort from 5.9.1 to 5.9.2 (aws-powertools#514) feat(mypy): add mypy support to makefile (aws-powertools#508) feat(api-gateway): add debug mode (aws-powertools#507)
…ent-subclass * develop: fix(api-gateway): non-greedy route pattern regex (aws-powertools#533) chore(deps): bump boto3 from 1.18.0 to 1.18.1 (aws-powertools#528) fix(tracer): mypy generic to preserve decorated method signature (aws-powertools#529) fix(parser): Make ApiGateway version, authorizer fields optional (aws-powertools#532) fix(mypy): fixes to resolve no implicit optional errors (aws-powertools#521) chore(deps): bump boto3 from 1.17.110 to 1.18.0 (aws-powertools#527)
Issue #, if available:
Description of changes:
Resolve mypy errors, down from 124 to 30 :-) .
Changes:
resolve_truthy_env_var_choiceChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.