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

[Bug]: symbols are not exported from apache_beam, causing type errors from Pylance #33437

Open
1 of 17 tasks
sebastian-correa opened this issue Dec 22, 2024 · 2 comments
Open
1 of 17 tasks
Assignees

Comments

@sebastian-correa
Copy link

What happened?

When doing

from apache_beam import Pipeline

Pylance complains about:

"Pipeline" is not exported from module "apache_beam". Import from "apache_beam.pipeline" insteadPylance[reportPrivateImportUsage (https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportPrivateImportUsage)

image

I think that that (and other symbols) imported in the packages __init__.py are meant to be part of the public interface. However, Pyalnce requires the following semantics to detect them as such:

Imported symbols are considered private by default. If they use the “import A as A” (a redundant module alias), “from X import A as A” (a redundant symbol alias), or “from . import A” forms, symbol “A” is not private unless the name begins with an underscore (...).
A module can expose an __all__ symbol at the module level that provides a list of names that are considered part of the interface. The __all__ symbol indicates which symbols are included in a wildcard import. All symbols included in the __all__ list are considered public even if the other rules above would otherwise indicate that they were private.

[source]

I propose that either redundant aliases or an __all__ be added to apache_beam's __init__.py to prevent this.

Probably the transforms module, which is * imported will need this done to it as well (and, well, recursively as transforms also imports other modules).

Issue Priority

Priority: 3 (minor)

Issue Components

  • Component: Python SDK
  • Component: Java SDK
  • Component: Go SDK
  • Component: Typescript SDK
  • Component: IO connector
  • Component: Beam YAML
  • Component: Beam examples
  • Component: Beam playground
  • Component: Beam katas
  • Component: Website
  • Component: Infrastructure
  • Component: Spark Runner
  • Component: Flink Runner
  • Component: Samza Runner
  • Component: Twister2 Runner
  • Component: Hazelcast Jet Runner
  • Component: Google Cloud Dataflow Runner
@sebastian-correa
Copy link
Author

.take-issue

@sebastian-correa
Copy link
Author

I'll tackle the issue, but will wait for some from the Beam team to confirm this is something they want and to voice an opinion on redundant aliases (my preference) vs __all__. This way, I don't open an unwanted PR.

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

No branches or pull requests

1 participant