Skip to content

Type checks for pd.options.display.* are not accurate #1230

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
mike-flowers-airbnb opened this issue May 28, 2025 · 1 comment · Fixed by #1231
Closed

Type checks for pd.options.display.* are not accurate #1230

mike-flowers-airbnb opened this issue May 28, 2025 · 1 comment · Fixed by #1231

Comments

@mike-flowers-airbnb
Copy link
Contributor

Describe the bug
Various display options underneath pd.options.display. do not have correct annotations per pandas documentation.

The following columns show mismatches between documented behavior compared to type check:

pd.describe_option('display.(?:colheader_justify|large_repr|max_columns|max_colwidth|max_dir_items|max_rows|max_seq_items|memory_usage|min_rows|show_dimensions)')

To Reproduce

import pandas as pd

# Overly restrictive types set, expect errors to not be raised
pd.options.display.max_columns = None
pd.options.display.max_colwidth = None
pd.options.display.max_dir_items = None
pd.options.display.max_rows = None
pd.options.display.max_seq_items = None
pd.options.display.min_rows = None

# Overly permissive values permitted, expect errors to be raised
pd.options.display.colheader_justify = "invalid_value"
pd.options.display.large_repr = "invalid_value"
pd.options.display.memory_usage = "invalid_value"
pd.options.display.show_dimensions = "invalid_value"
test.py:4: error: Incompatible types in assignment (expression has type "None", variable has type "int")  [assignment]
    pd.options.display.max_columns = None
                                     ^~~~
test.py:5: error: Incompatible types in assignment (expression has type "None", variable has type "int")  [assignment]
    pd.options.display.max_colwidth = None
                                      ^~~~
test.py:6: error: Incompatible types in assignment (expression has type "None", variable has type "int")  [assignment]
    pd.options.display.max_dir_items = None
                                       ^~~~
test.py:7: error: Incompatible types in assignment (expression has type "None", variable has type "int")  [assignment]
    pd.options.display.max_rows = None
                                  ^~~~
test.py:8: error: Incompatible types in assignment (expression has type "None", variable has type "int")  [assignment]
    pd.options.display.max_seq_items = None
                                       ^~~~
test.py:9: error: Incompatible types in assignment (expression has type "None", variable has type "int")  [assignment]
    pd.options.display.min_rows = None
                                  ^~~~
test.py:14: error: Incompatible types in assignment (expression has type "str", variable has type "bool")  [assignment]
    pd.options.display.memory_usage = "invalid_value"
                                      ^~~~~~~~~~~~~~~
Found 7 errors in 1 file (checked 1 source file)

Please complete the following information:

  • OS: MacOS
  • OS Version: 15.5
  • python version: 3.12
  • pandas version: 2.2.3
  • version of type checker: mypy 1.9.0
  • version of installed pandas-stubs: 2.2.3.250308

Additional context
I'm happy to do PR, just let me know if that's preferred

@loicdiridollou
Copy link
Member

Hi @mike-flowers-airbnb,

Thanks for the report you are entirely correct the annotations are overly strict beyond the types from the pandas repo. It would be good to realign with types recommended in the docs pandas/core/config_init.py.
PR with tests is welcome, feel free to take it otherwise I am happy to take care of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants