Skip to content

Fix reportPrivateImportUsage errors disappearing - #11237

Merged
Rich Chiodo (rchiodo) merged 1 commit into
microsoft:mainfrom
pt-anthropic:claude/fix-private-import-errors-QFgW4
Jan 30, 2026
Merged

Rich Chiodo (rchiodo) merged 1 commit into
microsoft:mainfrom
pt-anthropic:claude/fix-private-import-errors-QFgW4

Conversation

@pt-anthropic

@pt-anthropic Paul Tarjan (pt-anthropic) commented Jan 18, 2026 •

Copy link
Copy Markdown
Contributor

When a py.typed package was added to check paths (e.g., via command line), reportPrivateImportUsage errors would incorrectly disappear. This happened because addTrackedFile() was creating source files with isInPyTypedPackage=false without detecting the actual py.typed status.

The fix detects py.typed status using _getModuleImportInfoForFile() when adding tracked files, similar to how setFileOpened() already does. This ensures that files from py.typed packages are correctly marked even when added directly to check paths.

Added test case that reproduces the bug scenario with three packages where pkg_b re-imports from pkg_a without re-exporting, and pkg_c imports from pkg_b.

@pt-anthropic
Paul Tarjan (pt-anthropic) force-pushed the claude/fix-private-import-errors-QFgW4 branch 2 times, most recently from 1282409 to d904088 Compare January 18, 2026 06:40
@pt-anthropic

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Anthropic"

@pt-anthropic

Copy link
Copy Markdown
Contributor Author

Is there anything more you need from me here?

@pt-anthropic
Paul Tarjan (pt-anthropic) force-pushed the claude/fix-private-import-errors-QFgW4 branch from d904088 to eaa2bad Compare January 25, 2026 17:31
@rchiodo

Copy link
Copy Markdown
Collaborator

Thanks, LGTM

@github-actions

This comment has been minimized.

@pt-anthropic
Paul Tarjan (pt-anthropic) force-pushed the claude/fix-private-import-errors-QFgW4 branch from eaa2bad to ce67442 Compare January 30, 2026 18:35
@pt-anthropic

Copy link
Copy Markdown
Contributor Author

(fixed the lint errors)

@github-actions

This comment has been minimized.

@rchiodo

Copy link
Copy Markdown
Collaborator

Still more linter errors. You should be able to run 'npm run fix:prettier' from the root. Can you also merge this with the main branch?

Thanks

@pt-anthropic
Paul Tarjan (pt-anthropic) force-pushed the claude/fix-private-import-errors-QFgW4 branch from ce67442 to 3f52b2e Compare January 30, 2026 18:57
…is tracked

When a py.typed package was added to check paths (e.g., via command line),
reportPrivateImportUsage errors would incorrectly disappear. This happened
because addTrackedFile() was creating source files with isInPyTypedPackage=false
without detecting the actual py.typed status.

The fix detects py.typed status using _getModuleImportInfoForFile() when adding
tracked files, similar to how setFileOpened() already does. This ensures that
files from py.typed packages are correctly marked even when added directly to
check paths.

Added test case that reproduces the bug scenario with three packages where pkg_b
re-imports from pkg_a without re-exporting, and pkg_c imports from pkg_b.
@pt-anthropic
Paul Tarjan (pt-anthropic) force-pushed the claude/fix-private-import-errors-QFgW4 branch from 3f52b2e to f2ac586 Compare January 30, 2026 18:58
@pt-anthropic

Copy link
Copy Markdown
Contributor Author

Sorry about that. Rebased on master.

> check
> npm run check:syncpack && npm run check:eslint && npm run check:prettier


> check:syncpack
> syncpack list-mismatches


> check:eslint
> eslint .


> check:prettier
> prettier -c .

Checking formatting...
All matched files use Prettier code style!

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sympy (https://github.com/sympy/sympy)
+   .../projects/sympy/sympy/solvers/ode/ode.py:609:22 - error: Cannot access attribute "pop" for class "tuple[()]"
+     Attribute "pop" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:609:22 - error: Cannot access attribute "pop" for class "tuple[str, ...]"
+     Attribute "pop" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1515:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1516:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1526:9 - error: No overloads for "update" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1526:12 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1526:19 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update"
+     Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]"
+       "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]"
+         "__iter__" is not present (reportArgumentType)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1533:43 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1533:64 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1539:9 - error: No overloads for "update" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1539:12 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1539:19 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update"
+     Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]"
+       "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]"
+         "__iter__" is not present (reportArgumentType)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1546:43 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1546:74 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1552:9 - error: No overloads for "update" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1552:12 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1552:19 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update"
+     Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]"
+       "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]"
+         "__iter__" is not present (reportArgumentType)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1559:49 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:1559:70 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/sympy/sympy/solvers/ode/ode.py:1689:36 - error: Cannot access attribute "lhs" for class "Expr"
-     Attribute "lhs" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/solvers/ode/ode.py:1689:55 - error: Cannot access attribute "rhs" for class "Expr"
-     Attribute "rhs" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/solvers/ode/ode.py:1690:36 - error: Cannot access attribute "lhs" for class "Expr"
-     Attribute "lhs" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/solvers/ode/ode.py:1691:17 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
-   .../projects/sympy/sympy/solvers/ode/ode.py:1691:17 - error: Argument of type "Equality | BooleanFalse | BooleanTrue | Unknown | Expr" cannot be assigned to parameter "value" of type "Equality | BooleanFalse | BooleanTrue" in function "__setitem__"
-     Type "Equality | BooleanFalse | BooleanTrue | Unknown | Expr" is not assignable to type "Equality | BooleanFalse | BooleanTrue"
-       Type "Expr" is not assignable to type "Equality | BooleanFalse | BooleanTrue"
-         "Expr" is not assignable to "Equality"
-         "Expr" is not assignable to "BooleanFalse"
-         "Expr" is not assignable to "BooleanTrue" (reportArgumentType)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3378:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3378:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3379:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3379:38 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3380:14 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3381:14 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3382:14 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3394:50 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3395:50 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3396:50 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3436:5 - error: No overloads for "update" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3436:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3436:14 - error: Argument of type "Unknown | dict[Unknown, Unknown] | None" cannot be assigned to parameter "m" of type "Iterable[tuple[str, Unknown]]" in function "update"
+     Type "Unknown | dict[Unknown, Unknown] | None" is not assignable to type "Iterable[tuple[str, Unknown]]"
+       "None" is incompatible with protocol "Iterable[tuple[str, Unknown]]"
+         "__iter__" is not present (reportArgumentType)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3437:18 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3437:43 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3438:9 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3438:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3438:24 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3438:31 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3439:9 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3439:15 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3439:23 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3439:30 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3440:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3440:46 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3440:54 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3441:9 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3441:19 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3441:29 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3442:10 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3443:10 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3444:10 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3495:5 - error: No overloads for "update" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/ode/ode.py:3495:7 - error: "update" is not a known attribute of "None" (reportOptionalMemberAccess)

... (truncated 1206 lines) ...

prefect (https://github.com/PrefectHQ/prefect)
+   .../projects/prefect/src/integrations/prefect-aws/tests/deployments/test_steps.py:10:43 - error: "get_s3_client" is not exported from module "prefect_aws.deployments.steps"
+     Import from "integrations.prefect-aws.prefect_aws.s3" instead (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/experimental/test_bundles.py:205:24 - error: "typer" is not exported from module "prefect_aws.experimental.bundles.upload" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/experimental/test_bundles.py:258:24 - error: "typer" is not exported from module "prefect_aws.experimental.bundles.upload" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/experimental/test_bundles.py:285:24 - error: "typer" is not exported from module "prefect_aws.experimental.bundles.upload" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/experimental/test_bundles.py:439:25 - error: "typer" is not exported from module "prefect_aws.experimental.bundles.execute" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/experimental/test_bundles.py:462:25 - error: "typer" is not exported from module "prefect_aws.experimental.bundles.execute" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/experimental/test_bundles.py:482:25 - error: "typer" is not exported from module "prefect_aws.experimental.bundles.execute" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/workers/test_ecs_worker.py:23:5 - error: "AwsCredentials" is not exported from module "prefect_aws.workers.ecs_worker"
+     Import from "integrations.prefect-aws.prefect_aws.credentials" instead (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-aws/tests/workers/test_ecs_worker.py:28:5 - error: "get_prefect_image_name" is not exported from module "prefect_aws.workers.ecs_worker" (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-dask/tests/test_task_runners.py:10:26 - error: "DaskTaskRunner" is not exported from module "prefect_dask"
+     Import from "integrations.prefect-dask.prefect_dask.task_runners" instead (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-dask/tests/test_utils.py:6:26 - error: "DaskTaskRunner" is not exported from module "prefect_dask"
+     Import from "integrations.prefect-dask.prefect_dask.task_runners" instead (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-dask/tests/test_utils.py:6:42 - error: "get_async_dask_client" is not exported from module "prefect_dask"
+     Import from "integrations.prefect-dask.prefect_dask.utils" instead (reportPrivateImportUsage)
+   .../projects/prefect/src/integrations/prefect-dask/tests/test_utils.py:6:65 - error: "get_dask_client" is not exported from module "prefect_dask"
+     Import from "integrations.prefect-dask.prefect_dask.utils" instead (reportPrivateImportUsage)
- 5438 errors, 172 warnings, 0 informations
+ 5451 errors, 172 warnings, 0 informations

@rchiodo
Rich Chiodo (rchiodo) merged commit 66456ea into microsoft:main Jan 30, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants