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 stub files #951

Closed
jasonkuhrt opened this issue May 29, 2019 · 4 comments · Fixed by #2715
Closed

mypy stub files #951

jasonkuhrt opened this issue May 29, 2019 · 4 comments · Fixed by #2715

Comments

@jasonkuhrt
Copy link

jasonkuhrt commented May 29, 2019

mypy throws an error when ddtrace is in use:

image

It would be nice if this library could ship with stub files or be put on https://github.com/python/typeshed. I'm not sure how to do that yet but maybe someone here is.

More info from mypy side here https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports

@brettlangdon
Copy link
Member

@jasonkuhrt thank you for opening the request, this has been on my personal todo list for awhile.

I also do not know how to do it, but would love to try and find the time to do this.

@jasonkuhrt
Copy link
Author

@brettlangdon fwiw this is what we did locally in our project to satisfy mypy (we're only stubbing the parts we use, not complete, of course)

image

@brettlangdon
Copy link
Member

Nice! Thanks for sharing.

@meshy
Copy link

meshy commented May 20, 2021

I ended up creating a compat module so that I could use ddtrace.tracer.wrap without getting warnings:

from typing import Any, Callable, TypeVar

import ddtrace

# This allows us to use a type annotated ddtrace.tracer.wrap.
# First, we assign the name "trace" to ddtrace.tracer.wrap.
# Then, we assign a type:
# "trace" is a callable that takes arguments, and returns a function.
# That function takes another function as an argument and returns it.
F = TypeVar("F", bound=Callable[..., Any])
trace: Callable[..., Callable[[F], F]] = ddtrace.tracer.wrap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants