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

Type checking errors with datadog client due to private imports #830

Open
adamh-oai opened this issue Apr 24, 2024 · 3 comments
Open

Type checking errors with datadog client due to private imports #830

adamh-oai opened this issue Apr 24, 2024 · 3 comments
Labels
kind/bug Bug related issue stale Stale - Bot reminder

Comments

@adamh-oai
Copy link

Describe the bug
The documented way of accessing dogstatsd is from datadog import statsd. This is a re-export of another module, in datadog/__init__.py:

from datadog.dogstatsd import DogStatsd, statsd

Unfortunately, the typechecker in VSCode (pyright) flags this as use of a private module:

"statsd" is not exported from module "datadog".  Import from "datadog.dogstatsd.base" instead.

The fix for this is to use a convention for re-exporting a module publically is:

from datadog.dogstatsd import DogStatsd as DogStatsd, statsd as statsd

I would put up a PR for this but I'm not sure which modules are intended as public interfaces from the top-level module.

To Reproduce

Steps to reproduce the behavior:

Create a project with this pyproject.toml:

[tool.poetry]
name = "dd-type-repro"
version = "0.1.0"
description = ""
authors = ["Adam Hupp <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.11"
datadog = "*"
pyright = "^1.1.360"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

And put this in main.py:

from datadog import statsd

And run poetry run pyright:

/Users/adamh/dd-type-repro/main.py
  /Users/adamh/dd-type-repro/main.py:1:21 - error: "statsd" is not exported from module "datadog"
    Import from "datadog.dogstatsd.base" instead (reportPrivateImportUsage)
1 error, 0 warnings, 0 informations

Expected behavior
No type errors in normal use.

@adamh-oai adamh-oai added the kind/bug Bug related issue label Apr 24, 2024
Copy link

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

@github-actions github-actions bot added the stale Stale - Bot reminder label May 25, 2024
@tyleryle
Copy link

Issue is still active.

@tyleryle tyleryle removed the stale Stale - Bot reminder label May 28, 2024
Copy link

Thanks for your contribution!

This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of this project.

  2. Comment that the issue is still reproducible and include updated details requested in the issue template.

@github-actions github-actions bot added the stale Stale - Bot reminder label Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Bug related issue stale Stale - Bot reminder
Projects
None yet
Development

No branches or pull requests

2 participants