pydata / pydata/xarray

Inspecting arguments with accessors

Open
#7,234 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-typing
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

I recently read about the suggested approach to extending xarray here: Extending xarray 2

We have a lot of functions on xarray datasets that are domain-specific enough to spatial mosaics that I think I want to start using these.

One issue I am seeing so far is that when I use the accessor in jupyter notebook, the arguments and docs are inspected and returned, which makes it nice and usable. However, within vscode, it is unable to inspect the args. The side effect is slower development and no more type checking, which isn’t ideal. This is also an issue with the rio accessor.

Am I missing something here? Has anyone noticed this and is there an existing fix? This must also be an issue with pandas custom accessors, too. Is there a way to more officially register accessors within my packages entry points?

For example

## inside notebooks
ds.sp.my_function() # I can inspect as usual
ds.rio.write_crs() # I can inspect as usual

## inside vscode
ds.sp.my_function() # I can not inspect the args or their types
ds.rio.write_crs() # I can not inspect the args or their types

I have seen sphinx-autosummary-accessors — sphinx-autosummary-accessors documentation 1, but that only seems relevant for doc generation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Extending xarray 2 documentation and comparing accessor inspection in Jupyter Notebook and VS Code, including the rio accessor example. Determine whether official package entry-point registration can expose accessor signatures and types to VS Code; done should include either a supported implementation path or a documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.