pulumi / pulumi-policy

Pulumi's Policy as Code SDK, CrossGuard. Define infrastructure checks in code to enforce security, compliance, cost, and other practices, enforced at deployment time.
https://www.pulumi.com/docs/guides/crossguard/
Apache License 2.0
32 stars 4 forks source link

python: publicly export symbols #294

Closed justinvp closed 1 year ago

justinvp commented 1 year ago

While working on the hackathon project to add python policy decorators, I was running into reportPrivateImportUsage errors from pylance in VS Code:

Diagnostics for incorrect usage of symbol imported from a "py.typed" module that is not re-exported from that module.

In particular, we're doing the following:

If a file __init__.py uses the form “from .A import X”, symbol “A” is not private unless the name begins with an underscore (but “X” is still private).

...with the intention of exporting the X symbol, but per above it is private.

This change addresses the problem, by exporting the symbols using __all__.

Subsequently, we should consider prefixing all other modules with an underscore, as they really are intended to be private.