python / python/typeshed

How important is the `@_dispatchable` decorator in networkx?

Open
#14,462 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

Can this decorator be removed?

One obvious advantage for having it is to mirror runtime. It has some disadvantages though:

  1. I can't for the life of me find a way to use it on overloaded functions. Indeed looking at the stubs, overloaded functions are stripped of this decorator
  2. VS Code with Pylance does not show the documentation of the function on hover only when the decorator is used

I find the overload case very important that it outweighs the benefits of matching runtime. I also think the editor hover issue compelling on its own but one could argue that this should be discussed with the Pylance team instead.

I wonder if we could just get rid of the decorator altogether. Am I missing other reasons for having the decorator?

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 tracing uses of the @_dispatchable decorator in typeshed and comparing them with overloaded functions in the stubs. Investigate the runtime-mirroring rationale and the reported Pylance hover behavior. Done means reaching a decision on whether the decorator should remain and documenting or implementing that decision.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Refactor
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.