Skip to content

[Typing] Python type stubs - #218

Merged
apdavison merged 17 commits into
python-quantities:masterfrom
n-takumasa:typing
Apr 5, 2023
Merged

apdavison merged 17 commits into
python-quantities:masterfrom
n-takumasa:typing

Conversation

@n-takumasa

Copy link
Copy Markdown
Contributor

I am hoping that the great PR(#206) will be merged sooner.
So, I prepare some changes until mypy and pytest passed.

Notes

quantities/units/volume.pyi:21: error: Name "milliliter" already defined on line 8  [no-redef]
quantities/units/pressure.pyi:38: error: Name "barad" already defined on line 37  [no-redef]

Duplicate definitions. eg.: volume.py#L14 & volume.py#L38

quantities/units/__init__.py:75: error: Incompatible import of "pt" (imported name has type "UnitQuantity", local name has type "UnitLength")  [assignment]

The same abbreviation is assigned to different units.
printers_point @ length.py#L133 & US_liquid_pint @ volume.py#L100

quantities/typing/quantities.pyi:8: error: Type argument "Union[float, int]" of "dtype" must be a subtype of "generic"  [type-var]

I think npt.NDArray[Union[np.floating, np.integer]] will solve.
FYI: There is no need to write float | int since float also accepts int.
https://peps.python.org/pep-0484/#the-numeric-tower

quantities/__init__.py:283: error: Incompatible import of "dimensionless" (imported name has type Module, local name has type "Dimensionless")  [assignment]
quantities/__init__.py:287: error: Incompatible import of "dimensionless" (imported name has type Module, local name has type "Dimensionless")  [assignment]

from ... import * is the root cause, the next cause is duplicate variable and module names.

quantities/constants/mathematical.py:15: error: Argument "aliases" to "UnitConstant" has incompatible type "str"; expected "List[str]"  [arg-type]

It doesn't seem to be used, but I think it should be list[str] because it is confusing.

@apdavison
apdavison merged commit 8c7d610 into python-quantities:master Apr 5, 2023
@apdavison

Copy link
Copy Markdown
Contributor

Many thanks for pushing this over the line @n-takumasa !

@n-takumasa
n-takumasa deleted the typing branch April 7, 2023 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants