Use PEP 585 syntax in @python2/_ast, convert more TypeVars to _typeshed.Self, & # noqa a SQLAlchemy line (#6954)

* Manual fixes for `_ast` and `SQLAlchemy`

* Change more `TypeVar`s to `Self`, using script
This commit is contained in:
Alex Waygood
2022-01-18 19:15:34 +00:00
committed by GitHub
parent 989fe11806
commit cd93461225
9 changed files with 105 additions and 102 deletions

View File

@@ -1,10 +1,10 @@
from _typeshed import Self
from decimal import Decimal
from numbers import Integral, Rational, Real
from typing import TypeVar, Union, overload
from typing import Union, overload
from typing_extensions import Literal
_ComparableNum = Union[int, float, Decimal, Real]
_T = TypeVar("_T")
@overload
def gcd(a: int, b: int) -> int: ...
@@ -18,10 +18,10 @@ def gcd(a: Integral, b: Integral) -> Integral: ...
class Fraction(Rational):
@overload
def __new__(
cls: type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ...
) -> _T: ...
cls: type[Self], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ...
) -> Self: ...
@overload
def __new__(cls: type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ...
def __new__(cls: type[Self], __value: float | Decimal | str, *, _normalize: bool = ...) -> Self: ...
@classmethod
def from_float(cls, f: float) -> Fraction: ...
@classmethod