Skip to content

pyright reports errors in hightime #64

@bkeryan

Description

@bkeryan
PS C:\dev\hightime> poetry run pyright
c:\Dev\hightime\hightime\_datetime.py
  c:\Dev\hightime\hightime\_datetime.py:79:20 - error: Argument missing for parameter "day" (reportCallIssue)

This is because we're calling a pickle-specific overload of datetime.datetime that isn't in typeshed.

  c:\Dev\hightime\hightime\_datetime.py:86:18 - error: Argument of type "Unknown | bytes | str" cannot be assigned to parameter "year" of type "SupportsIndex" in function "__new__"
    Type "Unknown | bytes | str" is not assignable to type "SupportsIndex"
      "bytes" is incompatible with protocol "SupportsIndex"
        "__index__" is not present (reportArgumentType)
  c:\Dev\hightime\hightime\_datetime.py:87:19 - error: Argument of type "Unknown | None" cannot be assigned to parameter "month" of type "SupportsIndex" in function "__new__"
    Type "Unknown | None" is not assignable to type "SupportsIndex"
      "None" is incompatible with protocol "SupportsIndex"
        "__index__" is not present (reportArgumentType)
  c:\Dev\hightime\hightime\_datetime.py:88:17 - error: Argument of type "Unknown | None" cannot be assigned to parameter "day" of type "SupportsIndex" in function "__new__"
    Type "Unknown | None" is not assignable to type "SupportsIndex"
      "None" is incompatible with protocol "SupportsIndex"
        "__index__" is not present (reportArgumentType)

These are because the implementation doesn't have type hints.

  c:\Dev\hightime\hightime\_datetime.py:117:5 - error: "year" incorrectly overrides property of same name in class "date" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:118:5 - error: "month" incorrectly overrides property of same name in class "date" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:119:5 - error: "day" incorrectly overrides property of same name in class "date" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:120:5 - error: "hour" incorrectly overrides property of same name in class "datetime" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:121:5 - error: "minute" incorrectly overrides property of same name in class "datetime" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:122:5 - error: "second" incorrectly overrides property of same name in class "datetime" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:123:5 - error: "microsecond" incorrectly overrides property of same name in class "datetime" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:124:5 - error: "tzinfo" incorrectly overrides property of same name in class "datetime" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_datetime.py:125:5 - error: "fold" incorrectly overrides property of same name in class "datetime" (reportIncompatibleMethodOverride)

I don't know why hightime assigns these descriptors or why pyright complains about them.

  c:\Dev\hightime\hightime\_datetime.py:206:9 - error: Method "replace" overrides class "datetime" in an incompatible manner
    Parameter 9 name mismatch: base parameter is named "tzinfo", override parameter is named "femtosecond" (reportIncompatibleMethodOverride)

This seems like a Liskov Substitution Principle violation: calling replace with the positional parameters for datetime.datetime.replace will pass tzinfo in place of femtosecond. The constructor handles this situation but replace does not.

  c:\Dev\hightime\hightime\_datetime.py:309:16 - error: Operator "<" not supported for types "_NotImplementedType | Unknown | timedelta | Literal[-1, 0, 1]" and "Literal[0]"
    Operator "<" not supported for types "timedelta" and "Literal[0]" (reportOperatorIssue)
  c:\Dev\hightime\hightime\_datetime.py:313:16 - error: Operator "<=" not supported for types "_NotImplementedType | Unknown | timedelta | Literal[-1, 0, 1]" and "Literal[0]"
    Operator "<=" not supported for types "timedelta" and "Literal[0]" (reportOperatorIssue)
  c:\Dev\hightime\hightime\_datetime.py:317:16 - error: Operator ">" not supported for types "_NotImplementedType | Unknown | timedelta | Literal[-1, 0, 1]" and "Literal[0]"
    Operator ">" not supported for types "timedelta" and "Literal[0]" (reportOperatorIssue)
  c:\Dev\hightime\hightime\_datetime.py:321:16 - error: Operator ">=" not supported for types "_NotImplementedType | Unknown | timedelta | Literal[-1, 0, 1]" and "Literal[0]"
    Operator ">=" not supported for types "timedelta" and "Literal[0]" (reportOperatorIssue)

This is either #60 or a result of missing type hints.

  c:\Dev\hightime\hightime\_datetime.py:360:16 - error: Type "(self: Self@datetime, other: Unknown) -> (_NotImplementedType | Unknown | datetime)" is not assignable to declared type "(self: Self@date, value: timedelta, /) -> Self@date"
    Type "(self: Self@datetime, other: Unknown) -> (_NotImplementedType | Unknown | datetime)" is not assignable to type "(self: Self@date, value: timedelta, /) -> Self@date"
      Function return type "_NotImplementedType | Unknown | datetime" is incompatible with type "Self@date"
        Type "_NotImplementedType | Unknown | datetime" is not assignable to type "Self@datetime"
          Type "_NotImplementedType | Unknown | datetime" is not assignable to type "Self@datetime" (reportAssignmentType)

Missing type hints.

  c:\Dev\hightime\hightime\_datetime.py:465:21 - error: Cannot access attribute "days" for class "datetime"
    Attribute "days" is unknown (reportAttributeAccessIssue)
c:\Dev\hightime\hightime\_datetime.pyi
  c:\Dev\hightime\hightime\_datetime.pyi:7:5 - error: "min" overrides symbol of same name in class "datetime"
    Variable is mutable so its type is invariant
      Override type "datetime" is not the same as base type "datetime" (reportIncompatibleVariableOverride)
  c:\Dev\hightime\hightime\_datetime.pyi:8:5 - error: "max" overrides symbol of same name in class "datetime"
    Variable is mutable so its type is invariant
      Override type "datetime" is not the same as base type "datetime" (reportIncompatibleVariableOverride)
  c:\Dev\hightime\hightime\_datetime.pyi:9:5 - error: "resolution" overrides symbol of same name in class "date"
    Variable is mutable so its type is invariant
      Override type "timedelta" is not the same as base type "timedelta" (reportIncompatibleVariableOverride)

I was wondering why these aren't final...

  c:\Dev\hightime\hightime\_datetime.pyi:70:9 - error: Method "__sub__" overrides class "datetime" in an incompatible manner
    Override does not handle all overloads of base method (reportIncompatibleMethodOverride)
c:\Dev\hightime\hightime\_timedelta.py
  c:\Dev\hightime\hightime\_timedelta.py:160:5 - error: "days" incorrectly overrides property of same name in class "timedelta" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_timedelta.py:161:5 - error: "seconds" incorrectly overrides property of same name in class "timedelta" (reportIncompatibleMethodOverride)
  c:\Dev\hightime\hightime\_timedelta.py:162:5 - error: "microseconds" incorrectly overrides property of same name in class "timedelta" (reportIncompatibleMethodOverride)
c:\Dev\hightime\hightime\_timedelta.pyi
  c:\Dev\hightime\hightime\_timedelta.pyi:6:5 - error: "min" overrides symbol of same name in class "timedelta"
    Variable is mutable so its type is invariant
      Override type "timedelta" is not the same as base type "timedelta" (reportIncompatibleVariableOverride)
  c:\Dev\hightime\hightime\_timedelta.pyi:7:5 - error: "max" overrides symbol of same name in class "timedelta"
    Variable is mutable so its type is invariant
      Override type "timedelta" is not the same as base type "timedelta" (reportIncompatibleVariableOverride)
  c:\Dev\hightime\hightime\_timedelta.pyi:8:5 - error: "resolution" overrides symbol of same name in class "timedelta"
    Variable is mutable so its type is invariant
      Override type "timedelta" is not the same as base type "timedelta" (reportIncompatibleVariableOverride)
c:\Dev\hightime\tests\test_datetime.py
  c:\Dev\hightime\tests\test_datetime.py:306:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:308:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:310:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:312:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:314:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:316:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:318:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_datetime.py:320:9 - warning: Expression value is unused (reportUnusedExpression)
c:\Dev\hightime\tests\test_timedelta.py
  c:\Dev\hightime\tests\test_timedelta.py:469:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_timedelta.py:573:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_timedelta.py:576:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_timedelta.py:605:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_timedelta.py:650:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_timedelta.py:653:9 - warning: Expression value is unused (reportUnusedExpression)
  c:\Dev\hightime\tests\test_timedelta.py:656:9 - warning: Expression value is unused (reportUnusedExpression)
30 errors, 15 warnings, 0 informations

I haven't worked through these yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions