Skip to content

fix: replace deprecated pkg_resources namespace declaration#131

Open
Tranquil-Flow wants to merge 1 commit into
larksuite:v2_mainfrom
Tranquil-Flow:fix/pkg-resources-namespace
Open

fix: replace deprecated pkg_resources namespace declaration#131
Tranquil-Flow wants to merge 1 commit into
larksuite:v2_mainfrom
Tranquil-Flow:fix/pkg-resources-namespace

Conversation

@Tranquil-Flow
Copy link
Copy Markdown

Summary

Replace the deprecated pkg_resources.declare_namespace() namespace declaration in lark_oapi/ws/pb/google/__init__.py with the existing pkgutil.extend_path() fallback path.

Why

Importing this module currently emits:

UserWarning: pkg_resources is deprecated as an API ... Refrain from using this package or pin to Setuptools<81.

In newer setuptools environments, this can become a hard import failure when pkg_resources.declare_namespace is unavailable.

Notes

This is the same minimal approach as PR #124, but that PR is currently blocked by CLA because its commit author email is not associated with a GitHub user. Opening this replacement so the fix has an unblocked path to merge.

Fixes #108.
Refs #115.
Refs #124.

Verification

Ran a minimal import proof with warnings treated as errors:

python -W error::UserWarning - <<'PY'
import importlib.util
from pathlib import Path
p = Path('lark_oapi/ws/pb/google/__init__.py').resolve()
spec = importlib.util.spec_from_file_location(
    'lark_oapi.ws.pb.google',
    p,
    submodule_search_locations=[str(p.parent)],
)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
assert mod.__path__
print('ok: lark_oapi.ws.pb.google imports without pkg_resources warning')
PY

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 21, 2026

CLA assistant check
All committers have signed the CLA.

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.

UserWarning: pkg_resources is deprecated as an API

2 participants