mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-28 12:14:43 +00:00
feat: impl Eq, Hash, Ord
for Python module types
This commit is contained in:
parent
1691647fe7
commit
c94ac76262
4 changed files with 26 additions and 0 deletions
|
@ -4,6 +4,9 @@ time = pyimport "time"
|
||||||
.MAXYEAR: {9999}
|
.MAXYEAR: {9999}
|
||||||
|
|
||||||
.TimeDelta = 'timedelta': ClassType
|
.TimeDelta = 'timedelta': ClassType
|
||||||
|
.TimeDelta <: Eq
|
||||||
|
.TimeDelta <: Hash
|
||||||
|
.TimeDelta <: Ord
|
||||||
.TimeDelta.
|
.TimeDelta.
|
||||||
__call__: (days := Nat, seconds := Nat, microseconds := Nat, milliseconds := Nat, minutes := Nat, hours := Nat, weeks := Nat) -> .TimeDelta
|
__call__: (days := Nat, seconds := Nat, microseconds := Nat, milliseconds := Nat, minutes := Nat, hours := Nat, weeks := Nat) -> .TimeDelta
|
||||||
__eq__: (self: .TimeDelta, other: .TimeDelta) -> Bool
|
__eq__: (self: .TimeDelta, other: .TimeDelta) -> Bool
|
||||||
|
@ -17,6 +20,9 @@ time = pyimport "time"
|
||||||
resolution: .TimeDelta
|
resolution: .TimeDelta
|
||||||
total_seconds: (self: .TimeDelta) -> Float
|
total_seconds: (self: .TimeDelta) -> Float
|
||||||
.Date = 'date': ClassType
|
.Date = 'date': ClassType
|
||||||
|
.Date <: Eq
|
||||||
|
.Date <: Hash
|
||||||
|
.Date <: Ord
|
||||||
.Date.
|
.Date.
|
||||||
__call__: (year: Nat, month: Nat, day: Nat) -> .Date
|
__call__: (year: Nat, month: Nat, day: Nat) -> .Date
|
||||||
__eq__: (self: .Date, other: .Date) -> Bool
|
__eq__: (self: .Date, other: .Date) -> Bool
|
||||||
|
@ -45,7 +51,13 @@ time = pyimport "time"
|
||||||
max: .Date
|
max: .Date
|
||||||
resolution: .TimeDelta
|
resolution: .TimeDelta
|
||||||
.TZInfo = 'tzinfo': ClassType
|
.TZInfo = 'tzinfo': ClassType
|
||||||
|
.TZInfo <: Eq
|
||||||
|
.TZInfo <: Hash
|
||||||
|
.TZInfo <: Ord
|
||||||
.Time = 'time': ClassType
|
.Time = 'time': ClassType
|
||||||
|
.Time <: Eq
|
||||||
|
.Time <: Hash
|
||||||
|
.Time <: Ord
|
||||||
.Time.
|
.Time.
|
||||||
__call__: (hour: 0..23, minute: 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .Time
|
__call__: (hour: 0..23, minute: 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .Time
|
||||||
__eq__: (self: .Time, other: .Time) -> Bool
|
__eq__: (self: .Time, other: .Time) -> Bool
|
||||||
|
@ -61,6 +73,9 @@ time = pyimport "time"
|
||||||
replace: (self: .Time, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .Time
|
replace: (self: .Time, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .Time
|
||||||
isoformat: (self: .Time, timespec := Str) -> Str
|
isoformat: (self: .Time, timespec := Str) -> Str
|
||||||
.DateTime = 'datetime': ClassType
|
.DateTime = 'datetime': ClassType
|
||||||
|
.DateTime <: Eq
|
||||||
|
.DateTime <: Hash
|
||||||
|
.DateTime <: Ord
|
||||||
.DateTime.
|
.DateTime.
|
||||||
__call__: (year: 0..9999, month: 1..12, day: 1..31, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .DateTime
|
__call__: (year: 0..9999, month: 1..12, day: 1..31, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .DateTime
|
||||||
__eq__: (self: .DateTime, other: .DateTime) -> Bool
|
__eq__: (self: .DateTime, other: .DateTime) -> Bool
|
||||||
|
@ -87,6 +102,9 @@ time = pyimport "time"
|
||||||
replace: (self: .DateTime, year := 0..9999, month := 1..12, day := 1..31, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .DateTime
|
replace: (self: .DateTime, year := 0..9999, month := 1..12, day := 1..31, hour := 0..23, minute := 0..59, second := 0..59, microsecond := Nat, tzinfo := .TZInfo or NoneType) -> .DateTime
|
||||||
utcoffset: (self: .DateTime) -> .TimeDelta or NoneType
|
utcoffset: (self: .DateTime) -> .TimeDelta or NoneType
|
||||||
.TimeZone = 'timezone': ClassType
|
.TimeZone = 'timezone': ClassType
|
||||||
|
.TimeZone <: Eq
|
||||||
|
.TimeZone <: Hash
|
||||||
|
.TimeZone <: Ord
|
||||||
.TimeZone.
|
.TimeZone.
|
||||||
__eq__: (self: .TimeZone, other: .TimeZone) -> Bool
|
__eq__: (self: .TimeZone, other: .TimeZone) -> Bool
|
||||||
__ne__: (self: .TimeZone, other: .TimeZone) -> Bool
|
__ne__: (self: .TimeZone, other: .TimeZone) -> Bool
|
||||||
|
|
|
@ -85,6 +85,9 @@
|
||||||
.setcontext!: (ctx: .Context!) => NoneType
|
.setcontext!: (ctx: .Context!) => NoneType
|
||||||
.localcontext: (ctx := .Context!) -> .Context!
|
.localcontext: (ctx := .Context!) -> .Context!
|
||||||
|
|
||||||
|
.Decimal <: Eq
|
||||||
|
.Decimal <: Hash
|
||||||
|
.Decimal <: Ord
|
||||||
.Decimal.
|
.Decimal.
|
||||||
__call__: (value := Str or Float) -> .Decimal
|
__call__: (value := Str or Float) -> .Decimal
|
||||||
adjusted: (self: .Decimal) -> Int
|
adjusted: (self: .Decimal) -> Int
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
decimal = pyimport "decimal"
|
decimal = pyimport "decimal"
|
||||||
|
|
||||||
.Fraction: ClassType
|
.Fraction: ClassType
|
||||||
|
.Fraction <: Eq
|
||||||
|
.Fraction <: Hash
|
||||||
|
.Fraction <: Ord
|
||||||
.Fraction.
|
.Fraction.
|
||||||
numerator: Int
|
numerator: Int
|
||||||
denominator: Int
|
denominator: Int
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
.PurePath: ClassType
|
.PurePath: ClassType
|
||||||
.PurePath <: PathLike
|
.PurePath <: PathLike
|
||||||
|
.PurePath <: Eq
|
||||||
|
.PurePath <: Hash
|
||||||
.PurePath.
|
.PurePath.
|
||||||
parts: [Str; _]
|
parts: [Str; _]
|
||||||
drive: Str
|
drive: Str
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue