question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When I import a module I get a MyPy error from this library, e.g. Cannot find module named google.ads.google_ads.client

Possible solutions:

Can these be autogenerated easily? I’d be happy to help set this up if not.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
henribrucommented, Oct 25, 2019

Well, since I didn’t get a reply I just went ahead and published a stub package: https://pypi.org/project/google-ads-stubs/

Sadly inference from get_type and get_service isn’t working (read the caveats section). It still gives you autocomplete and type checking if you explicitly state the types though. It should also fix the problem with imports that was the original reason for this issue.

1reaction
henribrucommented, Jul 4, 2019

Since a lot of things in this repository are generated from protocol buffers, this is pretty closely related to https://github.com/protocolbuffers/protobuf/issues/2638. There’s actually a tip there about https://github.com/dropbox/mypy-protobuf, which allows you to create type stubs from the protobuf definitions.

I don’t think we can ever use type inference when getting types from string names like client.get_type('CustomerOperation').

This will actually be possible in Python 3.8 using literal types. https://www.python.org/dev/peps/pep-0586/

Read more comments on GitHub >

github_iconTop Results From Across the Web

mypy 0.991 documentation
Mypy has a powerful and easy-to-use type system, supporting features such as type inference, generics, callable types, tuple types, union types, structural ...
Read more >
mypy - Optional Static Typing for Python
Mypy is an optional static type checker for Python. ... The aim is to support almost all Python language constructs in mypy.
Read more >
Mypy: Static Typing for Python - GitHub
Mypy is a static type checker for Python. Type checkers help ensure that you're using variables and functions in your code correctly. With...
Read more >
Type Checking With Mypy - Real Python
In this lesson, you'll explore how to use Mypy to do type checking on your Python code. Mypy is the most common tool...
Read more >
Mypy Documentation - Read the Docs
Mypy is a static type checker for Python. Type checkers help ensure that you're using variables and functions in your code correctly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found