Skip to content

python 3.12 and pyright 1.1.334 error: Method "fromtimestamp" overrides class "datetime" in an incompatible manner #813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dangjinghao opened this issue Nov 5, 2023 · 3 comments · Fixed by #839

Comments

@dangjinghao
Copy link
Contributor

Describe the bug
I'm Follwing the setup.md to set up an development envirment. When I execute poe test_all .Pyright test cannot be finished and prints this error message.

To Reproduce

  1. Provide a minimal runnable pandas example that is not properly checked by the stubs.
    unit test in tests/
  2. Indicate which type checker you are using (mypy or pyright).
    pyright
  3. Show the error message received from that type checker while checking your example.
prompt> poe test_all                                                                         (pandas_stubs_test) 
Poe => test_all

===========================================
Beginning: 'Run mypy on 'tests' (using the local stubs) and on the local stubs'
===========================================

Success: no issues found in 224 source files

===========================================
End: 'Run mypy on 'tests' (using the local stubs) and on the local stubs', runtime: 27.658 seconds.
===========================================


===========================================
Beginning: 'Run pyright on 'tests' (using the local stubs) and on the local stubs'
===========================================

/pathto/pandas_stubs_test/pandas_stubs_v2/pandas-stubs/_libs/tslibs/timestamps.pyi
  /pathto/pandas_stubs_test/pandas_stubs_v2/pandas-stubs/_libs/tslibs/timestamps.pyi:103:9 - error: Method "fromtimestamp" overrides class "datetime" in an incompatible manner
    Parameter 2 name mismatch: base parameter is named "timestamp", override parameter is named "t" (reportIncompatibleMethodOverride)
1 error, 0 warnings, 0 informations 

===========================================
Step: 'Run pyright on 'tests' (using the local stubs) and on the local stubs' failed!
===========================================
  • OS: archlinux
  • OS Version kernel version: 6.5.8
  • python version 3.12.0
  • version of type checker pyright 1.1.334
  • version of installed pandas-stubs 2.1.1.230928

Additional context
I didn't modify anything in this project.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 6, 2023

I can't reproduce this.

This may be an issue in that you're using python 3.12. Can you try python 3.9 ?

Alternatively, try modifying pyproject.toml to use pyright 1.1.333 and do poetry update and see if that makes it go away, in which case the issue may be something to do with the pyright 1.1.334 and python 3.12 combination.

@dangjinghao
Copy link
Contributor Author

I can't reproduce this.

This may be an issue in that you're using python 3.12. Can you try python 3.9 ?

Alternatively, try modifying pyproject.toml to use pyright 1.1.333 and do poetry update and see if that makes it go away, in which case the issue may be something to do with the pyright 1.1.334 and python 3.12 combination.

Yes, there is not any issue in python 3.9 environment.Here are full logs,maybe useful
/home/user/py_code/pandas_stubs_test/pandas_stubs_v2 is the root dir of this project .
python 3.12.0+pyright v1.1.333,same error

prompt> poetry run poe test_all                               (pandas_stubs_test) 
Poe => test_all

===========================================
Beginning: 'Run mypy on 'tests' (using the local stubs) and on the local stubs'
===========================================

Success: no issues found in 224 source files

===========================================
End: 'Run mypy on 'tests' (using the local stubs) and on the local stubs', runtime: 27.663 seconds.
===========================================


===========================================
Beginning: 'Run pyright on 'tests' (using the local stubs) and on the local stubs'
===========================================

WARNING: there is a new pyright version available (v1.1.333 -> v1.1.334).
Please install the new version or set PYRIGHT_PYTHON_FORCE_VERSION to `latest`

/home/user/py_code/pandas_stubs_test/pandas_stubs_v2/pandas-stubs/_libs/tslibs/timestamps.pyi
  /home/user/py_code/pandas_stubs_test/pandas_stubs_v2/pandas-stubs/_libs/tslibs/timestamps.pyi:103:9 - error: Method "fromtimestamp" overrides class "datetime" in an incompatible manner
    Parameter 2 name mismatch: base parameter is named "timestamp", override parameter is named "t" (reportIncompatibleMethodOverride)
1 error, 0 warnings, 0 informations 

===========================================
Step: 'Run pyright on 'tests' (using the local stubs) and on the local stubs' failed!
===========================================

python 3.9.18+pyright 1.1.334

prompt> poetry run poe test_all                               (pandas_stubs_3.9) 
Poe => test_all

===========================================
Beginning: 'Run mypy on 'tests' (using the local stubs) and on the local stubs'
===========================================

Success: no issues found in 224 source files

===========================================
End: 'Run mypy on 'tests' (using the local stubs) and on the local stubs', runtime: 25.405 seconds.
===========================================


===========================================
Beginning: 'Run pyright on 'tests' (using the local stubs) and on the local stubs'
===========================================

0 errors, 0 warnings, 0 informations 

===========================================
End: 'Run pyright on 'tests' (using the local stubs) and on the local stubs', runtime: 17.495 seconds.
===========================================


===========================================
Beginning: 'Run pytest'
===========================================

==================================================== test session starts =====================================================
platform linux -- Python 3.9.18, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/user/py_code/pandas_stubs_test/pandas_stubs_v2
collected 992 items                                                                                                          

tests/test_api_types.py ...........................................                                                    [  4%]
tests/test_config.py ...                                                                                               [  4%]
tests/test_dtypes.py ..........                                                                                        [  5%]
tests/test_errors.py .........................s..........                                                              [  9%]
tests/test_extension.py ..                                                                                             [  9%]
tests/test_frame.py .................................................................................s................ [ 19%]
........................................................................                                               [ 26%]
tests/test_holidays.py .                                                                                               [ 26%]
tests/test_indexes.py ...............................                                                                  [ 29%]
tests/test_interval.py .....                                                                                           [ 30%]
tests/test_interval_index.py ......                                                                                    [ 30%]
tests/test_io.py ................ss...............................................s...                                 [ 37%]
tests/test_merge.py .                                                                                                  [ 38%]
tests/test_pandas.py ............................                                                                      [ 40%]
tests/test_plotting.py ........................                                                                        [ 43%]
tests/test_resampler.py ...............................                                                                [ 46%]
tests/test_scalars.py .............................                                                                    [ 49%]
tests/test_series.py ................................................................................................. [ 59%]
............................................................sss....................................................... [ 70%]
...................................................................................................................... [ 82%]
.......................................................................                                                [ 90%]
tests/test_styler.py ...........................                                                                       [ 92%]
tests/test_testing.py ...                                                                                              [ 93%]
tests/test_timefuncs.py .............................................                                                  [ 97%]
tests/test_utility.py ....                                                                                             [ 97%]
tests/test_windowing.py ....................                                                                           [100%]

============================================== 984 passed, 8 skipped in 16.05s ===============================================

===========================================
End: 'Run pytest', runtime: 16.561 seconds.
===========================================


===========================================
Beginning: 'Run pre-commit'
===========================================

black....................................................................Passed
- hook id: black
- duration: 0.17s

All done! ✨ 🍰 ✨
230 files left unchanged.

isort....................................................................Passed
- hook id: isort
- duration: 0.43s
ruff.....................................................................Passed
- hook id: ruff
- duration: 0.06s
codespell................................................................Passed
- hook id: codespell
- duration: 0.22s

===========================================
End: 'Run pre-commit', runtime: 1.078 seconds.
===========================================


===========================================
Beginning: 'Build pandas-stubs'
===========================================

Building pandas-stubs (2.1.1.230928)
  - Building wheel
  - Built pandas_stubs-2.1.1.230928-py3-none-any.whl

===========================================
End: 'Build pandas-stubs', runtime: 0.996 seconds.
===========================================


===========================================
Beginning: 'Install pandas-stubs'
===========================================

Processing ./dist/pandas_stubs-2.1.1.230928-py3-none-any.whl
Collecting numpy>=1.26.0 (from pandas-stubs==2.1.1.230928)
  Using cached numpy-1.26.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
Collecting types-pytz>=2022.1.1 (from pandas-stubs==2.1.1.230928)
  Using cached types_pytz-2023.3.1.1-py3-none-any.whl.metadata (1.3 kB)
Using cached numpy-1.26.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
Using cached types_pytz-2023.3.1.1-py3-none-any.whl (4.9 kB)
Installing collected packages: types-pytz, numpy, pandas-stubs
  Attempting uninstall: types-pytz
    Found existing installation: types-pytz 2023.3.1.1
    Uninstalling types-pytz-2023.3.1.1:
      Successfully uninstalled types-pytz-2023.3.1.1
  Attempting uninstall: numpy
    Found existing installation: numpy 1.26.1
    Uninstalling numpy-1.26.1:
      Successfully uninstalled numpy-1.26.1
Successfully installed numpy-1.26.1 pandas-stubs-2.1.1.230928 types-pytz-2023.3.1.1

===========================================
End: 'Install pandas-stubs', runtime: 2.857 seconds.
===========================================


===========================================
Beginning: 'Rename local stubs'
===========================================


===========================================
End: 'Rename local stubs', runtime: 0.000 seconds.
===========================================


===========================================
Beginning: 'Run mypy on 'tests' using the installed stubs'
===========================================

Success: no issues found in 26 source files

===========================================
End: 'Run mypy on 'tests' using the installed stubs', runtime: 24.801 seconds.
===========================================


===========================================
Beginning: 'Run pyright on 'tests' using the installed stubs'
===========================================

File or directory "/home/user/py_code/pandas_stubs_test/pandas_stubs_v2/pandas-stubs" does not exist.
0 errors, 0 warnings, 0 informations 

===========================================
End: 'Run pyright on 'tests' using the installed stubs', runtime: 16.167 seconds.
===========================================


===========================================
Undoing: Rename local stubs
===========================================


===========================================
Undoing: Install pandas-stubs
===========================================

Found existing installation: pandas-stubs 2.1.1.230928
Uninstalling pandas-stubs-2.1.1.230928:
  Successfully uninstalled pandas-stubs-2.1.1.230928

BTW, the logs of python 3.9 envrioment containes File or directory "/home/user/py_code/pandas_stubs_test/pandas_stubs_v2/pandas-stubs" does not exist.. Is thie serious?

@Dr-Irv Dr-Irv changed the title poe test_all error: Method "fromtimestamp" overrides class "datetime" in an incompatible manner python 3.12 and pyright 1.1.334 error: Method "fromtimestamp" overrides class "datetime" in an incompatible manner Nov 7, 2023
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Nov 7, 2023

Thanks for the tests.

It sounds like with python 3.12, we have a failure with the latest version of pyright and the typeshed stubs.

I don't think the error you received in the python 3.9 environment is an issue.

I've updated the title of the issue since it will allow us to focus on what is wrong.

@twoertwein twoertwein mentioned this issue Dec 23, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants