Skip to content

Commit

Permalink
Fix type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
lycantropos committed Nov 1, 2024
1 parent 508b85a commit 58d6cbc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
12 changes: 6 additions & 6 deletions rithm/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from typing_extensions import Self

class Endianness:
BIG: Endianness = ...
LITTLE: Endianness = ...
BIG: Endianness
LITTLE: Endianness

@property
def value(self) -> int: ...
Expand All @@ -17,10 +17,10 @@ def __new__(cls, value: int, /) -> Self: ...
def __repr__(self) -> str: ...

class TieBreaking:
AWAY_FROM_ZERO: TieBreaking = ...
TO_EVEN: TieBreaking = ...
TO_ODD: TieBreaking = ...
TOWARD_ZERO: TieBreaking = ...
AWAY_FROM_ZERO: TieBreaking
TO_EVEN: TieBreaking
TO_ODD: TieBreaking
TOWARD_ZERO: TieBreaking

@property
def value(self) -> int: ...
Expand Down
11 changes: 11 additions & 0 deletions rithm/fraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def __new__(
cls, numerator: Int | int, denominator: Int | int, /
) -> Self: ...

def __new__(
cls,
numerator: Self | Int | _Rational | float | int = ...,
denominator: Int | int = ...,
/,
) -> Self: ...

def __abs__(self, /) -> Self: ...

def __add__(self, other: Self | Int | int, /) -> Self: ...
Expand All @@ -48,6 +55,8 @@ def __eq__(self, other: Self | Int | int, /) -> bool: ...
@overload
def __eq__(self, other: Any, /) -> Any: ...

def __eq__(self, other: Any, /) -> Any: ...

def __float__(self, /) -> float: ...

def __floor__(self, /) -> Int: ...
Expand Down Expand Up @@ -96,6 +105,8 @@ def __round__(self, digits: None = ..., /) -> Int: ...
@overload
def __round__(self, digits: int, /) -> Self: ...

def __round__(self, digits: int | None = ..., /) -> Self | Int: ...

def __rsub__(self, subtrahend: Int | int, /) -> Self: ...

def __str__(self, /) -> str: ...
Expand Down
9 changes: 9 additions & 0 deletions rithm/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def __new__(cls, value: Self | float | int = ..., /) -> Self: ...
@overload
def __new__(cls, value: str, base: int | None = ..., /) -> Self: ...

def __new__(
cls,
value: Self | float | int | str = ...,
base: int | None = ...,
/,
) -> Self: ...

def __abs__(self, /) -> Self: ...

def __add__(self, other: Self | int, /) -> Self: ...
Expand All @@ -54,6 +61,8 @@ def __eq__(self, other: Self | int, /) -> bool: ...
@overload
def __eq__(self, other: Any, /) -> Any: ...

def __eq__(self, other: Any, /) -> Any: ...

def __float__(self, /) -> float: ...

def __floor__(self, /) -> Self: ...
Expand Down
19 changes: 12 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from __future__ import annotations

import platform
from typing import Any

from setuptools import (find_packages,
setup)
from setuptools import find_packages, setup

project_base_url = 'https://github.com/lycantropos/rithm/'
parameters = dict(packages=find_packages(exclude=('tests', 'tests.*')),
url=project_base_url,
download_url=project_base_url + 'archive/master.zip')
parameters: dict[str, Any] = dict(
packages=find_packages(exclude=('tests', 'tests.*')),
url=project_base_url,
download_url=project_base_url + 'archive/master.zip',
)
if platform.python_implementation() == 'CPython':
from setuptools_rust import RustExtension

parameters.update(rust_extensions=[RustExtension('rithm._crithm')],
zip_safe=False)
parameters.update(
rust_extensions=[RustExtension('rithm._crithm')], zip_safe=False
)
setup(**parameters)

0 comments on commit 58d6cbc

Please sign in to comment.