Skip to content

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

Closed
@mike-flowers-airbnb

Description

@mike-flowers-airbnb

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions