Skip to content

Conversation

@rbavery
Copy link
Member

@rbavery rbavery commented Jan 12, 2026

Summary

addresses #17

  • Fix Wkl.__getattr__ to reject private/dunder attributes (e.g., __version__, __name__) instead of treating them as location chains
  • Expose __version__ on the wkls instance using importlib.metadata

Problem

Because wkls replaces its module with a Wkl() instance (sys.modules[__name__] = wkls_instance), accessing any dunder attribute like wkls.__version__ triggers Wkl.__getattr__("__version__").

Previously, this would:

  1. Create a location chain ['__version__']
  2. Run a SQL query treating __VERSION__ as a country code
  3. Return an empty ChainableDataFrame
>>> print(wkls.__version__)
Empty ChainableDataFrame
Columns: [id, country, region, subtype, name_primary, name_en]
Index: []

Solution

  1. Add a check in Wkl.__getattr__ to raise AttributeError for attributes starting with _ (matching the existing behavior in ChainableDataFrame.__getattr__)
  2. Set __version__ directly on the wkls instance using importlib.metadata.version("wkls"), with a fallback to "0.0.0.dev" for development environments where the package isn't installed

@rbavery rbavery marked this pull request as ready for review January 13, 2026 00:13
Copy link
Member

@prantogg prantogg left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@prantogg prantogg merged commit 69e835c into wherobots:main Jan 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants