You can turn this setting off by setting an override in settings.json:

  "python.analysis.diagnosticSeverityOverrides": {
    "reportPrivateImportUsage":"none" 
  }

You can also set it to "warning" or "information" for less intrusive notifications.

Answer from Marcin on Stack Overflow
Top answer
1 of 2
12

You can turn this setting off by setting an override in settings.json:

  "python.analysis.diagnosticSeverityOverrides": {
    "reportPrivateImportUsage":"none" 
  }

You can also set it to "warning" or "information" for less intrusive notifications.

2 of 2
2

The answer by @Marcin correctly points out the way to disable this check, but it doesn't explain why.

The check is there for a reason, and by disabling it without understanding said reason, you are setting yourself up for a potential fail.

What are private imports?

"Private imports" are symbols imported by a module that are not re-exported by that same module.

To give an example, let's say there's a library named pets that provides pets and their foods:

# pets/foods.py
__all__ = ['Tuna', <other foods here...>]

class Tuna(Food): ...
# pets/cats.py
from .foods import Tuna

class Cat:
  def eat(self, food: Food) -> None: ...

def feed_cat(cat: Cat) -> None:
  food = Tuna()
  cat.eat(food)

Now, from your code, you do this:

# your_house.py
from pets.cats import Tuna  # !?

This import will not fail at runtime, since Tuna is imported into cats.py, but you should instead import it from pets.foods, where it is originally defined.

cats.py imports Tuna because that symbol is necessary for feed_cat()'s implementation, but nothing guarantees Tuna will always be present in that module. If feed_cat() were to be changed to use Chicken, the Tuna import would be removed and your code would thus break.

See also: What does __all__ mean in Python?, Why use `from module import A as A` instead of just `from module import A`.

Conclusion

The cat feeder who lives in the cat house might have a can of tuna, but they are not who you should get your tuna from.

You ought to go to the food storage instead:

from pets.cats import Tuna   # bad
from pets.foods import Tuna  # good

Sometimes, however, it might be the library which is in the wrong by not re-exporting things properly. If you think this is the case, filing an issue at the library's bug tracker would be a good start.

🌐
GitHub
github.com › microsoft › pylance-release › blob › main › docs › diagnostics › reportPrivateImportUsage.md
pylance-release/docs/diagnostics/reportPrivateImportUsage.md at main · microsoft/pylance-release
reportPrivateImportUsage flags cases where imports from private modules or symbols are used in a way that exposes internal implementation details.
Author   microsoft
🌐
GitHub
github.com › roboflow › supervision › issues › 1681
Pyright reportPrivateImportUsage error on supervision.Detections · Issue #1681 · roboflow/supervision
November 24, 2024 - After supervision added py.typed support, Pyright is reporting a reportPrivateImportUsage error when trying to use Detections type from the package's root import, even though it's explicitly re-exported in the package's __init__.py.
Author   anriha
🌐
GitHub
github.com › microsoft › pyright › issues › 2639
reportPrivateImportUsage error on public-looking symbol defined with relative import · Issue #2639 · microsoft/pyright
November 30, 2021 - Describe the bug Prefect defines a symbol with from .kubernetes import ECSRun in src/prefect/run_configs/__init__.py, but I get a reportPrivateImportUsage error from pyright when I have from prefect.run_configs import ECSRun in my application.
Author   aripollak
🌐
GitHub
github.com › microsoft › pyright › issues › 8377
`reportPrivateImportUsage` false negatives when running `pyright <directory>` but not when running `find <directory> -name '*.py' | xargs pyright` · Issue #8377 · microsoft/pyright
July 11, 2024 - <path-to-repo>/lib/common/tests/external_clients/openweather/test_openweather.py <path-to-repo>/lib/common/tests/external_clients/openweather/test_openweather.py:8:36 - error: "WeatherState" is not exported from module "common.db.sites.models" Import from "common.db.sites.objects" instead (reportPrivateImportUsage)
Author   tamird
🌐
GitHub
github.com › openapi-generators › openapi-python-client › issues › 675
VSCode pylance raised `reportPrivateImportUsage` error. · Issue #675 · openapi-generators/openapi-python-client
September 26, 2022 - Describe the bug In vscode, current templates will cause pylance to raises the reportPrivateImportUsage. To Reproduce try.py from the_client import AuthenticatedClient from the_client.api.the_tag import get_stuff from the_client.models i...
Author   EltonChou
🌐
GitHub
github.com › scrapy › scrapy › issues › 6578
pyright reports scrapy imports as private · Issue #6578 · scrapy/scrapy
December 10, 2024 - reportPrivateImportUsage [boolean or string, optional]: Generate or suppress diagnostics for use of a symbol from a "py.typed" > module that is not meant to be exported from that module.
Author   paulcwatts
🌐
GitHub
github.com › pallets › flask › issues › 4548
pyright reportPrivateImportUsage error with typical imports · Issue #4548 · pallets/flask
April 21, 2022 - $ pyright server.py Searching for source files Found 1 source file server.py server.py:4:26 - error: "Response" is not exported from module "flask.app" Import from "flask.wrappers" instead (reportPrivateImportUsage) 1 error, 0 warnings, 0 informations Completed in 1.155sec ·
Author   gitpushdashf
Find elsewhere
🌐
GitHub
github.com › OpenAPITools › openapi-generator › issues › 20878
[BUG][python] Clients throws reportPrivateImportUsage when used as a package · Issue #20878 · OpenAPITools/openapi-generator
[BUG][python] Clients throws reportPrivateImportUsage when used as a package#20878 · Copy link · Labels · Issue: Bug · robertleeplummerjr · opened · on Mar 13, 2025 · Issue body actions · Have you provided a full/minimal spec to reproduce the issue? Have you validated the input using an OpenAPI validator (example)?
🌐
GitHub
github.com › microsoft › pyright › issues › 5872
reportPrivateImportUsage for an exported import · Issue #5872 · microsoft/pyright
September 1, 2023 - Describe the bug When importing ExecutionEngine from great_expectations.execution_engine I get a "reportPrivateImportUsage" error saying I should import it from great_expectations.execution_engine.execution_engine, even though it is imported inside of "great_expectations/execution_engine/__init__.py" and there is no __all__ defined there.
Author   amotzop
🌐
GitHub
github.com › microsoft › pyright › issues › 4287
`reportPrivateImportUsage` error from exported import of an imported name · Issue #4287 · microsoft/pyright
# try_import.py from exporttest import _Assigned # OK from exporttest import Imported # reportPrivateImportUsage error!
🌐
GitHub
github.com › Project-MONAI › MONAI › issues › 3031
Monai generates lots of Pyright/pylance errors (reportPrivateImportUsage) · Issue #3031 · Project-MONAI/MONAI
September 27, 2021 - Monai generates lots of Pyright/pylance errors (reportPrivateImportUsage)#3031 · Copy link · Labels · questionFurther information is requestedFurther information is requested · dyollb · opened · on Sep 27, 2021 · Issue body actions · Describe the bug Pyright complains about import statements like: from monai.metrics import DiceMetric, ConfusionMatrixMetric from monai.losses import DiceLoss ·
Author   dyollb
🌐
GitHub
github.com › huggingface › datasets › issues › 3841
Pyright reportPrivateImportUsage when `from datasets import load_dataset` · Issue #3841 · huggingface/datasets
`load_dataset` is not exported from module "datasets" Import from "datasets.load" instead [reportPrivateImportUsage] Importing from datasets.load does indeed solves the problem but I believe importing directly from top level datasets is the intended usage per the documentation.
🌐
GitHub
github.com › microsoft › pyright › issues › 2451
Issues with jax: reportPrivateImportUsage · Issue #2451 · microsoft/pyright
October 18, 2021 - Describe the bug Some public APIs from the jax library are recognized as error: for example, "PRNGKey" is not exported from module "jax.random" (reportPrivateImportUsage) To Rep...
Author   wookayin
🌐
GitHub
github.com › simple-salesforce › simple-salesforce › issues › 723
pyright reportPrivateImportUsage linting failure · Issue #723 · simple-salesforce/simple-salesforce
April 15, 2024 - To repro from simple_salesforce import Salesforce, SFType Running pyright on this code returns the following issue: error: "Salesforce" is not exported from module "simple_salesforce" Import from "simple_salesforce.api" instead (reportPr...
Author   philipbjorge
🌐
GitHub
github.com › microsoft › pyright › issues › 2392
reportPrivateImportUsage confused by library source · Issue #2392 · microsoft/pyright
Describe the bug The Library rich (pip install rich) currently generates the reportPrivateImportUsage error: /home/gregory/Downloads/testcase/pytest/ricchy.py:5:16 - error: "Live" is not exported from module "rich.box.live" (reportPrivat...
🌐
GitHub
github.com › unionai-oss › pandera › issues › 1726
Pyright does not recognize pandera.polars exports: reportPrivateImportUsage · Issue #1726 · unionai-oss/pandera
July 3, 2024 - Describe the bug Pyright throws reportPrivateImportUsage errors on basically everything imported from pandera.polars. I have checked that this issue has not already been reported. I have confirmed this bug exists on the latest version of...
Author   RmStorm
🌐
GitHub
github.com › jd › tenacity › issues › 329
reportPrivateImportUsage is detected by pyright · Issue #329 · jd/tenacity
September 14, 2021 - reportPrivateImportUsage is now detected in pyright 1.1.168. https://github.com/microsoft/pyright/releases/tag/1.1.168 I don't know much, but the cause seems to be an empty "tenacity/py.typed". #221 code target code from tenacity import ...
Author   yamap55
🌐
Basedpyright
docs.basedpyright.com › latest › benefits-over-pyright › new-diagnostic-rules
new diagnostic rules - basedpyright
pyright's reportPrivateImportUsage rule only checks for private imports of third party modules inside py.typed packages. but there's no reason your own code shouldn't be subject to the same restrictions.