python / python/typeshed

numbers module

Open
#11,863 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

image
The signature of Rational.__truediv__ is marked as the following:
image
First of, _ComplexLike sounds like it should be numbers.Complex. But second, the signature should be more refined :

  • the divisor cannot be just any value, it has to be a number, so at a minimum numbers.Complex instead of Unknown. The typing signature should be (self, Complex) -> Complex.
  • when passing a Real as a divisor, the result cannot have an imaginary part and must be Real too. I'd go as far as saying that a Rational divisor would yield a Rational dividend. In any case, a (self, Real) -> Real overload should be defined. And as a bonus, a (self, Rational) -> Rational one too.

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 at the typeshed numbers module and inspect the declaration of Rational.truediv. Compare its current _ComplexLike and Unknown annotations with the requested Complex, Real, and Rational overloads. Done means the stub expresses the requested divisor and result relationships and passes the relevant typeshed validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.