typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Add more precise but flexible typing for statistics, time, and datetime.

Open Flameeyes opened this issue 1 year ago • 1 comments

Flameeyes avatar Jun 20 '24 11:06 Flameeyes

Diff from mypy_primer, showing the effect of this PR on open source code:

pandas (https://github.com/pandas-dev/pandas)
+ pandas/_libs/tslibs/timestamps.pyi:88: error: Signature of "fromtimestamp" incompatible with supertype "date"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:88: note:      Superclass:
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          def fromtimestamp(cls, SupportsInt, /) -> Timestamp
+ pandas/_libs/tslibs/timestamps.pyi:88: note:      Subclass:
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          @classmethod
+ pandas/_libs/tslibs/timestamps.pyi:88: note:          def fromtimestamp(cls, ts: float, tz: str | tzinfo | int | None = ...) -> Timestamp
+ pandas/_libs/tslibs/timestamps.pyi:88: error: Argument 1 of "fromtimestamp" is incompatible with supertype "datetime"; supertype defines the argument type as "SupportsInt"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:88: note: This violates the Liskov substitution principle
+ pandas/_libs/tslibs/timestamps.pyi:88: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ pandas/_libs/tslibs/timestamps.pyi:90: error: Argument 1 of "utcfromtimestamp" is incompatible with supertype "datetime"; supertype defines the argument type as "SupportsInt"  [override]
+ pandas/_libs/tslibs/timestamps.pyi:90: note: This violates the Liskov substitution principle
+ pandas/_libs/tslibs/timestamps.pyi:90: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/solr/updater/work.py: note: In member "number_of_pages_median" of class "WorkSolrBuilder":
+ openlibrary/solr/updater/work.py:377: error: Value of type variable "_NumberT" of "median" cannot be "int"  [type-var]

pandas-stubs (https://github.com/pandas-dev/pandas-stubs)
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: error: Signature of "fromtimestamp" incompatible with supertype "date"  [override]
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note:      Superclass:
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note:          @classmethod
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note:          def fromtimestamp(cls, SupportsInt, /) -> Timestamp
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note:      Subclass:
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note:          @classmethod
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note:          def fromtimestamp(cls, t: float, tz: tzinfo | str | None = ...) -> Timestamp
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: error: Argument 1 of "fromtimestamp" is incompatible with supertype "datetime"; supertype defines the argument type as "SupportsInt"  [override]
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note: This violates the Liskov substitution principle
+ pandas-stubs/_libs/tslibs/timestamps.pyi:107: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ pandas-stubs/_libs/tslibs/timestamps.pyi:115: error: Argument 1 of "utcfromtimestamp" is incompatible with supertype "datetime"; supertype defines the argument type as "SupportsInt"  [override]
+ pandas-stubs/_libs/tslibs/timestamps.pyi:115: note: This violates the Liskov substitution principle
+ pandas-stubs/_libs/tslibs/timestamps.pyi:115: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

github-actions[bot] avatar Jun 20 '24 12:06 github-actions[bot]

Thanks for contributing! I'm closing this PR for now, because it still has unresolved review feedback (and a merge conflict) after three months of inactivity. If you are still interested, please feel free to open a new PR (or ping us to reopen this one).

JelleZijlstra avatar Oct 03 '24 04:10 JelleZijlstra