Skip to content

Extend check for inconsistent pandas namespace usage #38093

Closed
@MarcoGorelli

Description

@MarcoGorelli

xref #38076 - it can probably be extended beyond checking for classes.

Steps would be:

  1. change PATTERN in scripts/check_for_inconsistent_pandas_namespace.py to
PATTERN = r"""
    (
        (?<!pd\.)(?<!\w)    # check class_name doesn't start with pd. or character
        (\w+)\(        # match DataFrame but not pd.DataFrame or tm.makeDataFrame
        .*                  # match anything
        pd\.\2\(            # only match e.g. pd.DataFrame
    )|
    (
        pd\.(\w+)\(    # only match e.g. pd.DataFrame
        .*                  # match anything
        (?<!pd\.)(?<!\w)    # check class_name doesn't start with pd. or character
        \4\(                # match DataFrame but not pd.DataFrame or tm.makeDataFrame
    )
    """

and save.

  1. run pre-commit run inconsistent-namespace-usage --all-files, check the error messages, and fix them up

Here are the files which need fixing:

- [ ] pandas/tests/arrays/floating/test_to_numpy
- [ ] pandas/tests/extension/decimal/test_decimal
- [ ] pandas/tests/io/test_sql
- [ ] pandas/tests/series/test_constructors
- [ ] pandas/tests/arrays/test_datetimes
- [ ] pandas/tests/frame/test_stack_unstack
- [ ] pandas/tests/arrays/boolean/test_comparison
- [ ] pandas/tests/internals/test_internals
- [ ] pandas/tests/arrays/masked/test_arrow_compat
- [ ] pandas/tests/reshape/merge/test_multi
- [ ] pandas/tests/indexing/test_datetime
- [ ] pandas/tests/scalar/timestamp/test_unary_ops

This can probably all be one in a single PR.

  1. To check you've fixed up a file completely, running
pre-commit run inconsistent-namespace-usage --files <file.py>

should return "PASSED".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions