Comments (10)
@tuukkamustonen there is a new branch that addresses this issue: https://github.com/vemel/mypy_boto3_builder/pull/47
Should be released in a couple of days.
from mypy_boto3_builder.
I think this bug happens to all clients. I get it with EC2, Organizations, SSM, StepFunctions.
Based on my understanding how types work I think PyCharm is right (assuming SSMClient is child of BaseClient), but mypy doesn't show this error.
from mypy_boto3_builder.
@vlasovskikh since you're working on PyCharm, can you tell if there's something wrong with these stubs?
from mypy_boto3_builder.
Having the same issue with PyCharm 2020.2 (didn't try earlier) and:
boto3 1.14.47
boto3-stubs 1.14.47.0
mypy-boto3 1.14.47.0
mypy-boto3-s3 1.14.47.0
import boto3
from mypy_boto3_s3 import S3Client
client: S3Client = boto3.client('s3')
Navigating to boto3.client()
goes to site-packages/mypy_boto3/boto3_init_gen.py
which shows:
# pylint: disable=unused-argument
def client(
service_name: str,
region_name: str = None,
api_version: str = None,
use_ssl: bool = None,
verify: Union[str, bool] = None,
endpoint_url: str = None,
aws_access_key_id: str = None,
aws_secret_access_key: str = None,
aws_session_token: str = None,
config: Config = None,
) -> BaseClient:
pass
So it indeed returns BaseClient
and not S3Client
.
Actually, interesting that boto3-stubs
hijacks the navigation like that. How can I navigate (Ctrl+click) to the actual boto3 function then?
from mypy_boto3_builder.
Hello guys,
Thank you for the report. I have not found any cleaner way to annotate client classes.
As a workaround, you can run mypy_boto3
, it will generate overloads in site-packages/mypy_boto3/boto3_init_gen.py
.
If you have any suggestion - please let me know.
from mypy_boto3_builder.
The latest release should fix this issue. Thank you for the report. Let me know if still does not work correctly.
from mypy_boto3_builder.
@vemel I still see the issue on 1.14.51.1 for ec2: EC2Client = boto3.client("ec2", region_name=region)
Wouldn't setting boto3.client
's result to Any
fix it?
from mypy_boto3_builder.
Interestingly ec2: EC2ServiceResource = boto3.resource("ec2", region_name=region)
is not highlighted. So, is there anything that's different between client()
and resource()
?
from mypy_boto3_builder.
THere is a difference, but I was sure I fixed both cases. Could you please try mypy on this code sample? https://github.com/vemel/mypy_boto3_builder/blob/master/examples/s3_example.py
The difference could be that client
returns botocore.BaseClient
, but resource() -> Any
.
from mypy_boto3_builder.
@vemel Unfortunately, 1.14.53.0 still returns BaseClient
for .client()
... .resource()
is indeed Any
.
I did pip uninstall
+ pip install
(instead of pip install -U
) to ensure there wouldn't be leftovers from previous version.
from mypy_boto3_builder.
Related Issues (20)
- `InstanceTypeDef` gone in `mypy-boto3-ec2==1.28.3.post1` HOT 5
- "TypeError: duplicate base class object" for types-aiobotocore-dynamodb version 2.5.2.post1 HOT 3
- Mypy-boto3-appflow 1.28.12 has inconsistent typing HOT 15
- Regression boto3-stubs[dynamodb] Table.get_item typing HOT 4
- Wrong types for IAMClient.get_policy_version HOT 2
- Shorten package descriptions for compatibility with Azure DevOps mirroring, pipelines HOT 3
- Return type incorrect for DynamoDb Client methods HOT 2
- The query paginator returns unexpected Type QueryOutputTableTypeDef HOT 2
- upload_fileobj types in S3Client are wrong. HOT 3
- Corrupt tarball for mypy-boto3-ec2 on PyPI HOT 2
- Include TypeDef for Cloudwatch Alarms Events from EventBridge HOT 10
- Support configuration of `typing` vs `typing_extensions` HOT 4
- [sts] GetCallerIdentityResponseTypeDef -> Arn should be 'str' but ist dict[str, Any] HOT 3
- GetKeyPolicyResponseTypeDef Policy should be `str` not `Dict[str, Any]` HOT 4
- dynamo: AttributeBase does not include `name` property HOT 2
- Client package ServiceName literal definitions are not necessarily up-to-date HOT 2
- pyright now treats TypedDict field types as invariant instead of covariant resulting in some type checking errors HOT 5
- session.get_credentials() has become optional HOT 2
- ListUserPoolClientsResponseTypeDef : NextToken should be not required HOT 3
- Sub-resources do not inherit correct `.meta.client` type HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mypy_boto3_builder.