diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 039b3c4e4d86c..08dbb5e86b42e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -59,10 +59,6 @@ repos: - flake8==5.0.4 - flake8-bugbear==22.7.1 - pandas-dev-flaker==0.5.0 -- repo: https://github.com/pycqa/pylint - rev: v2.15.3 - hooks: - - id: pylint - repo: https://github.com/PyCQA/isort rev: 5.10.1 hooks: @@ -281,3 +277,8 @@ repos: - autotyping==22.9.0 - black==22.6.0 - libcst==0.4.7 + - id: pylint + name: Pylint + entry: python -m pylint.__main__ + language: system + files: \.py$ diff --git a/environment.yml b/environment.yml index fed5ecb779045..66a51984b000b 100644 --- a/environment.yml +++ b/environment.yml @@ -50,6 +50,7 @@ dependencies: - sqlalchemy - tabulate - tzdata>=2022a + - vulture - xarray - xlrd - xlsxwriter diff --git a/pandas/conftest.py b/pandas/conftest.py index 14d156acdf4de..214bc76c12ea1 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -81,8 +81,10 @@ zoneinfo = None if pd.compat.PY39: # Import "zoneinfo" could not be resolved (reportMissingImports) + # pylint: disable=import-error import zoneinfo # type: ignore[no-redef] + # pylint: enable=import-error # Although zoneinfo can be imported in Py39, it is effectively # "not available" without tzdata/IANA tz data. # We will set zoneinfo to not found in this case diff --git a/pandas/tests/indexes/datetimes/test_constructors.py b/pandas/tests/indexes/datetimes/test_constructors.py index d129f5b365ca4..a466a09e32706 100644 --- a/pandas/tests/indexes/datetimes/test_constructors.py +++ b/pandas/tests/indexes/datetimes/test_constructors.py @@ -15,7 +15,6 @@ OutOfBoundsDatetime, astype_overflowsafe, ) -from pandas.compat import PY39 import pandas as pd from pandas import ( @@ -32,8 +31,8 @@ period_array, ) -if PY39: - import zoneinfo +if pd.compat.PY39: + import zoneinfo # pylint: disable=import-error class TestDatetimeIndex: @@ -1151,7 +1150,7 @@ def test_timestamp_constructor_retain_fold(tz, fold): _tzs = ["dateutil/Europe/London"] -if PY39: +if pd.compat.PY39: try: _tzs = ["dateutil/Europe/London", zoneinfo.ZoneInfo("Europe/London")] except zoneinfo.ZoneInfoNotFoundError: diff --git a/pandas/tests/io/excel/test_readers.py b/pandas/tests/io/excel/test_readers.py index fa1d6bbfd5a7e..f0ff0e3ed9cfc 100644 --- a/pandas/tests/io/excel/test_readers.py +++ b/pandas/tests/io/excel/test_readers.py @@ -841,7 +841,7 @@ def test_read_from_pathlib_path(self, read_ext): def test_read_from_py_localpath(self, read_ext): # GH12655 - from py.path import local as LocalPath + from py.path import local as LocalPath # pylint: disable=import-error str_path = os.path.join("test1" + read_ext) expected = pd.read_excel(str_path, sheet_name="Sheet1", index_col=0) diff --git a/pandas/tests/io/pytables/test_read.py b/pandas/tests/io/pytables/test_read.py index 4b57bc8291442..e98db4fc7b79f 100644 --- a/pandas/tests/io/pytables/test_read.py +++ b/pandas/tests/io/pytables/test_read.py @@ -6,6 +6,7 @@ from pandas._libs.tslibs import Timestamp from pandas.compat import is_platform_windows +import pandas.util._test_decorators as td import pandas as pd from pandas import ( @@ -21,7 +22,6 @@ ensure_clean_path, ensure_clean_store, ) -from pandas.util import _test_decorators as td from pandas.io.pytables import TableIterator @@ -293,7 +293,7 @@ def test_read_from_pathlib_path(setup_path): def test_read_from_py_localpath(setup_path): # GH11773 - from py.path import local as LocalPath + from py.path import local as LocalPath # pylint: disable=import-error expected = DataFrame( np.random.rand(4, 5), index=list("abcd"), columns=list("ABCDE") diff --git a/pandas/tests/io/sas/test_sas7bdat.py b/pandas/tests/io/sas/test_sas7bdat.py index cee416ac218de..06d42c2c68e2a 100644 --- a/pandas/tests/io/sas/test_sas7bdat.py +++ b/pandas/tests/io/sas/test_sas7bdat.py @@ -84,7 +84,7 @@ def test_path_pathlib(self, dirpath, data_test_ix): @td.skip_if_no("py.path") @pytest.mark.slow def test_path_localpath(self, dirpath, data_test_ix): - from py.path import local as LocalPath + from py.path import local as LocalPath # pylint: disable=import-error df0, test_ix = data_test_ix for k in test_ix: diff --git a/pyproject.toml b/pyproject.toml index 3e87d237170aa..3b7ffe255138a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,13 @@ exclude = ''' ) ''' +[tool.pylint.main] +ignore-patterns = ["^\\.#"] +ignore = [ + "versioneer.py", + "validate_min_versions_in_sync.py" +] + [tool.pylint.messages_control] max-line-length = 88 disable = [ @@ -42,9 +49,10 @@ disable = [ "bad-super-call", "c-extension-no-member", "function-redefined", - "import-error", +# "import-error", "inherit-non-class", "invalid-repr-returned", + "invalid-sequence-index", "invalid-unary-operand-type", "misplaced-bare-raise", "no-member", diff --git a/requirements-dev.txt b/requirements-dev.txt index e5dc2f1bb97a4..d7b3432629509 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -41,6 +41,7 @@ scipy sqlalchemy tabulate tzdata>=2022.1 +vulture xarray xlrd xlsxwriter