Skip to content

fix(bindings/python): improve the typing discovering of the python package#7180

Merged
PsiACE merged 1 commit intoapache:mainfrom
frostming:fix/python
Feb 5, 2026
Merged

fix(bindings/python): improve the typing discovering of the python package#7180
PsiACE merged 1 commit intoapache:mainfrom
frostming:fix/python

Conversation

@frostming
Copy link
Copy Markdown
Contributor

@frostming frostming commented Feb 5, 2026

Which issue does this PR close?

Closes #.

Rationale for this change

Currently the opendal python package exposes top level submodules so users can use it directly without needing to import them separately:

import opendal
opendal.file.File

However, due to the fact they are exported by the binding so, the typing info are missing. Because we generate typing stubs *.pyi under the same directory, we need to import them in __init__.py as well.

Also, the __version__ attribute was never imported actually, leading to an AttributeError when accessing opendal.__version__.

What changes are included in this PR?

  • improve the typing discovery by importing typing stubs under TYPE_CHECKING guard.
  • Expose version attribute correctly.

Are there any user-facing changes?

Since all changes are typing level and guarded by if TYPE_CHECKING, it should not have any impact on runtime behavior.

AI Usage Statement

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. releases-note/fix The PR fixes a bug or has a title that begins with "fix" labels Feb 5, 2026
package.

Expose __version__ attribute correctly.
Copy link
Copy Markdown
Member

@PsiACE PsiACE left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Feb 5, 2026
@PsiACE PsiACE merged commit f12c891 into apache:main Feb 5, 2026
62 checks passed
@frostming frostming deleted the fix/python branch February 6, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/fix The PR fixes a bug or has a title that begins with "fix" size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants