The Wayback Machine - https://web.archive.org/web/20201208100807/https://github.com/pandas-dev/pandas/issues/38093
Skip to content
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

Extend check for inconsistent pandas namespace usage #38093

Open
MarcoGorelli opened this issue Nov 26, 2020 · 3 comments · May be fixed by #38347
Open

Extend check for inconsistent pandas namespace usage #38093

MarcoGorelli opened this issue Nov 26, 2020 · 3 comments · May be fixed by #38347
Assignees

Comments

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Nov 26, 2020

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".

@kevinetienne
Copy link

@kevinetienne kevinetienne commented Nov 30, 2020

take

@MarcoGorelli
Copy link
Member Author

@MarcoGorelli MarcoGorelli commented Dec 6, 2020

Hi @kevinetienne - are you still working on this?

@kevinetienne
Copy link

@kevinetienne kevinetienne commented Dec 7, 2020

Yes, I have work I need to push, which I'll do today. Thank you.

@kevinetienne kevinetienne linked a pull request that will close this issue Dec 7, 2020
2 of 3 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.