Skip to content

python: Use deterministic import#227

Open
Venefilyn wants to merge 1 commit into
whtsky:masterfrom
Venefilyn:py/deterministic-import
Open

python: Use deterministic import#227
Venefilyn wants to merge 1 commit into
whtsky:masterfrom
Venefilyn:py/deterministic-import

Conversation

@Venefilyn

Copy link
Copy Markdown

Adds explicit imports and __all__ to __init__.py to explicitly
mention the methods available to use upon importing the pixelmatch
library.

Signed-off-by: Freya Gustavsson freya@venefilyn.se

Adds explicit imports and `__all__` to `__init__.py` to explicitly
mention the methods available to use upon importing the `pixelmatch`
library.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
@sonarqubecloud

Copy link
Copy Markdown

@whtsky

whtsky commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Could you please elaborate on the reason for this change?

@Venefilyn

Copy link
Copy Markdown
Author

Could you please elaborate on the reason for this change?

I ran into F405 on Ruff when vendoring it in Cockpit for wildcard import. And then F401 on Ruff for re-exporting. Both made sense to me

@whtsky

whtsky commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Thanks for clarifying. The current __init__.py intentionally re-exports all public names from core and utils. If there's anything we don't want export, we'd prefix it with _ to follow the Python convention to mark it as private.
Given that, manually listing all exports feels like adding an extra source of truth. I'm not sure there's much practical benefit from it.
While I understand this change do make Ruff happy, I don't think F405&F401 really fit in this case. I feel it may be better handled downstream by excluding/ignoring the vendored package, or adding a targeted ignore for these rules.

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.

2 participants