update to CatalogNamespace#98
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves static typing support for the dynamic datacat / reportcat catalog namespaces so editors can better infer types (per Issue #68), by marking the package as typed and introducing a typed namespace wrapper.
Changes:
- Add
py.typedand package configuration to ship type information in sdists/wheels. - Introduce
CatalogNamespace(aSimpleNamespacesubclass) and update catalog construction to use it. - Add
TYPE_CHECKINGattribute declarations to help editors resolve endpoint methods on dynamic access chains.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pyproject.toml | Ensures py.typed is included in built distributions. |
| MANIFEST.in | Includes py.typed in source distributions. |
| cfa/dataops/py.typed | Marks cfa.dataops as a typed package (PEP 561). |
| cfa/dataops/catalog.py | Adds CatalogNamespace + typing annotations to improve type inference for datacat chains. |
Comments suppressed due to low confidence (1)
cfa/dataops/catalog.py:772
dict_to_sntypesdefaultsas optional (dict | None) but immediately passes it toDatasetEndpoint(which expects adict) and later indexes into it (defaults["storage"][...]). Add an early check to narrow the type (and raise a clear error) or makedefaultsnon-optional in the signature/docstring.
def dict_to_sn(d: Any, defaults: dict | None = None, ns: str = "") -> CatalogNamespace:
"""Simple recursive namespace construction
Args:
d (Any): a dict, list or other
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Is this working for you locally? My editor isn't picking it up. I tried an alternative approach in #109, which seems more appropriate with the cost of being much more complicated. |
|
I don't think mine is picking it up either. I'm not as familiar with using type hints so I was copying over your other code with the most recent version of the main branch. I like your new PR. That might be the way to go. |
Generate precise catalog type stubs
I merged it in here |
|
this is working great for me now |
|
@damonbayer is this working for you? I think we're good to merge |
|
@ryanraaschCDC fine by me! Feels a bit fragile but I think it's worthy of trying more seriously. |
|
could you approve this PR then? Thanks! |
This includes the same updates as in #68 but is up to date with the main branch.