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

STYLE use pandas-dev-flaker #40906

Merged
merged 10 commits into from
Apr 16, 2021
Merged

Conversation

MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Apr 12, 2021


This means that, just by running flake8, you'll be able to get all these custom linting errors alongside the regular flake8 ones. E.g. if we make pandas/tests/t.py as follows:

import pytest

import pandas as pd
from pandas import Categorical


def test_foo():
    cat_0 = pd.Categorical([1])
    with pytest.warns(FutureWarning):
        cat_1 = pd.Categorical(1)

then we get:

$ flake8 pandas/tests/t.py 
pandas/tests/t.py:4:1: F401 'pandas.Categorical' imported but unused
pandas/tests/t.py:8:5: F841 local variable 'cat_0' is assigned to but never used
pandas/tests/t.py:8:13: PDF019 found both 'pd.Categorical' and 'Categorical' in the same file
pandas/tests/t.py:9:10: PDF011 found 'pytest.warns' (use 'pandas._testing.assert_produces_warning')
pandas/tests/t.py:10:9: F841 local variable 'cat_1' is assigned to but never used
pandas/tests/t.py:10:17: PDF019 found both 'pd.Categorical' and 'Categorical' in the same file

These can then easily be configured using flake8's configuration options, like # noqa and per-file-ignores in setup.cfg.

This also brings down the number of pre-commit checks.


I this is something the team wants, and it's decided to keep it as a separate repo, then some outstanding things to do would be:

  • transferring it to pandas-dev
  • sorting out the license (it's currently in my name, and I presume that should change)

@jbrockmendel
Copy link
Member

i dont know the code for these checks very well; is there any need for concern about the Marco bus factor?

@MarcoGorelli
Copy link
Member Author

i dont know the code for these checks very well; is there any need for concern about the Marco bus factor?

That's definitely a valid concern. What I'd like to first understand is whether you'd find this change useful - if so, then I can do my best to address concerns.

Just to clarify the bus factor question - is the concern more the repo being in my name, or about how most maintainers might not have ast-parsing at the top of their interest list and so this'd be hard to maintain going forward?
If the former, then we could either include it directly inside the pandas repo (as preferred by @dsaxton ) or I could share all access rights with the team. If the latter, then perhaps I could write a guide on how it works, how to debug it, and how to add new checks?

@jreback jreback added the Code Style Code style, linting, code_checks label Apr 13, 2021
@jreback
Copy link
Contributor

jreback commented Apr 13, 2021

generally looks good. I think including it as a pandas-dev repo is totally fine

@MarcoGorelli
Copy link
Member Author

Thanks @jreback - I've transferred it to pandas-dev/pandas-dev-flaker

For authors / license, am I OK to put "PyData Development Team" (as in the pandas license)?

@jreback
Copy link
Contributor

jreback commented Apr 13, 2021

Thanks @jreback - I've transferred it to pandas-dev/pandas-dev-flaker

For authors / license, am I OK to put "PyData Development Team" (as in the pandas license)?

sure that sounds good. I would add https://github.com/pandas-dev/pandas/tree/master/LICENSES as well

@MarcoGorelli MarcoGorelli marked this pull request as draft April 13, 2021 13:53
@MarcoGorelli MarcoGorelli marked this pull request as ready for review April 13, 2021 19:55
@MarcoGorelli MarcoGorelli requested a review from jreback April 13, 2021 19:55
@MarcoGorelli
Copy link
Member Author

I've fixed up the author, and the pandas license is there (https://github.com/pandas-dev/pandas-dev-flaker/blob/main/LICENSES/PANDAS_LICENSE)

Any further thoughts? If this is still seen as potentially controversial, maybe it can be discussed at the dev meeting tomorrow?

@jbrockmendel
Copy link
Member

Just to clarify the bus factor question - is the concern more the repo being in my name, or about how most maintainers might not have ast-parsing at the top of their interest list and so this'd be hard to maintain going forward?

The second one. I'm not losing sleep over it.

@jreback jreback added this to the 1.3 milestone Apr 14, 2021
@jreback
Copy link
Contributor

jreback commented Apr 14, 2021

lgtm.
cc @WillAyd @datapythonista if any concerns.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this - great work @MarcoGorelli

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice clean up, thanks @MarcoGorelli

Just a minor personal opinion on the pandas-dev-flaker, this PR looks good.

Instead of using from pandas_dev_flaker.__main__ import run, I'd personally define run in __init__.py, and import it from __main__.py, and from the tests or anywhere else needed with from pandas_dev_flaker import run.

Personally I think __main__.py should be exclusively for when calling python -m module, and nothing should be imported from it. I think that's the original purpose, and keep things better organized.

In any case, just a small suggestion, changes look great.

@MarcoGorelli
Copy link
Member Author

Thanks for your feedback, really appreciate it!

Thanks @datapythonista for the tip - I'll move definitions to __init__ when the next release comes around

@jreback jreback merged commit 1f27ed0 into pandas-dev:master Apr 16, 2021
@jreback
Copy link
Contributor

jreback commented Apr 16, 2021

very nice @MarcoGorelli

@MarcoGorelli MarcoGorelli deleted the pandas-dev-flaker branch April 16, 2021 07:17
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request Apr 21, 2021
yeshsurya pushed a commit to yeshsurya/pandas that referenced this pull request May 6, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
MarcoGorelli pushed a commit to MarcoGorelli/pandas that referenced this pull request Dec 31, 2022
MarcoGorelli added a commit that referenced this pull request Jan 5, 2023
* Revert "STYLE use pandas-dev-flaker (#40906)"

This reverts commit 1f27ed0.

* fixups

* fixup?

* make _compressors public

* use typing.Callable

* reduce diff

* further reduce

* one more

* fixup regex

* fixup regex

* add xfail to request

* remove else after xfail mark

* make copy_on_write public

Co-authored-by: MarcoGorelli <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Style Code style, linting, code_checks
Projects
None yet
5 participants