From 5313fd5c2b1ce97ef700525cac864484494c7cff Mon Sep 17 00:00:00 2001 From: Felipe Date: Wed, 17 Apr 2024 13:56:17 -0700 Subject: [PATCH] Fix warning message + update lint versions --- Makefile | 2 +- RELEASE.md | 2 +- copulas/__init__.py | 2 +- pyproject.toml | 41 ++++++++++++++-------------- setup.cfg | 24 +++++++++++----- tasks.py | 2 +- tests/unit/multivariate/test_tree.py | 10 +++---- tests/unit/test___init__.py | 4 +-- 8 files changed, 48 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 6969c923..d46145d8 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ lint-docs: ## check docs formatting with doc8 and pydocstyle fix-lint: ## fix lint issues using autoflake, autopep8, and isort find copulas tests -name '*.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables autopep8 --in-place --recursive --aggressive copulas tests - isort --apply --atomic --recursive copulas tests + isort --apply --atomic copulas tests # TEST TARGETS diff --git a/RELEASE.md b/RELEASE.md index 60284854..084b9b59 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -73,7 +73,7 @@ And you will see something like this: ``` ============================ 169 passed, 1 skipped, 3 warnings in 7.10s ============================ flake8 copulas tests examples -isort -c --recursive copulas tests examples +isort -c copulas tests examples ``` The execution has finished with no errors, 1 test skipped and 3 warnings. diff --git a/copulas/__init__.py b/copulas/__init__.py index 3c7d8b5b..bf40e3d8 100644 --- a/copulas/__init__.py +++ b/copulas/__init__.py @@ -321,7 +321,7 @@ def _find_addons(): try: addon = entry_point.load() except Exception: # pylint: disable=broad-exception-caught - msg = f'Failed to load "{entry_point.name}" from "{entry_point.module_name}".' + msg = f'Failed to load "{entry_point.name}" from "{entry_point.version}".' warnings.warn(msg) continue diff --git a/pyproject.toml b/pyproject.toml index c35696ee..a578563a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,32 +90,32 @@ dev = [ "Jinja2>=2,<4;python_version>='3.12'", # style check - 'flake8>=3.7.7,<4', - 'isort>=4.3.4,<5', - 'flake8-debugger>=4.0.0,<4.1', - 'flake8-mock>=0.3,<0.4', - 'flake8-mutable>=1.2.0,<1.3', - 'flake8-fixme>=1.1.1,<1.2', - 'pep8-naming>=0.12.1,<0.13', - 'dlint>=0.11.0,<0.12', + 'flake8>=3.7.7,<8', + 'flake8-absolute-import>=1.0,<2', + 'flake8-builtins>=1.5.3,<3', + 'flake8-comprehensions>=3.6.1,<4', + 'flake8-debugger>=4.0.0,<5', 'flake8-docstrings>=1.5.0,<2', - 'pydocstyle>=6.1.1,<6.2', - 'flake8-pytest-style>=1.5.0,<2', - 'flake8-comprehensions>=3.6.1,<3.7', - 'flake8-print>=4.0.0,<4.1', - 'flake8-expression-complexity>=0.0.9,<0.1', + 'flake8-eradicate>=1.1.0,<2', + 'flake8-fixme>=1.1.1,<1.2', + 'flake8-mock>=0.3,<1', 'flake8-multiline-containers>=0.0.18,<0.1', - 'pandas-vet>=0.2.2,<0.3', - 'flake8-builtins>=1.5.3,<1.6', - 'flake8-eradicate>=1.1.0,<1.2', + 'flake8-mutable>=1.2.0,<1.3', + 'flake8-expression-complexity>=0.0.9,<0.1', + 'flake8-print>=4.0.0,<4.1', + 'flake8-pytest-style>=2.0.0,<3', 'flake8-quotes>=3.3.0,<4', + 'flake8-sfs>=0.0.3,<2', 'flake8-variables-names>=0.0.4,<0.1', - 'flake8-sfs>=0.0.3,<0.1', - 'flake8-absolute-import>=1.0,<2', + 'dlint>=0.11.0,<1', + 'isort>=4.3.4,<6', + 'pandas-vet>=0.2.3,<2024', + 'pep8-naming>=0.12.1,<1', + 'pydocstyle>=6.1.1,<7', # fix style issues - 'autoflake>=1.1,<2', - 'autopep8>=1.4.3,<1.6', + 'autoflake>=1.1,<3', + 'autopep8>=1.4.3,<3', # distribute on PyPI 'twine>=1.10.0,<4', @@ -141,7 +141,6 @@ line_length = 99 lines_between_types = 0 multi_line_output = 4 use_parentheses = true -not_skip = ['__init__.py'] [tool.pydocstyle] convention = 'google' diff --git a/setup.cfg b/setup.cfg index 92037528..6e9c4d8e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,13 +1,23 @@ [flake8] max-line-length = 99 exclude = docs, .git, __pycache__, .ipynb_checkpoints -extend-ignore = D107, # Missing docstring in __init__ - D413, # Missing blank line after last section - DUO103, # insecure use of "pickle" or "cPickle" - N803, # argument name 'X' should be lowercase - N806, # variable 'X' in function should be lowercase - SFS3, # String literal formatting using f-string. - VNE001 # Single letter variable names are not allowed +extend-ignore = + # Missing docstring in __init__ + D107, + # Missing blank line after last section + D413, + # insecure use of "pickle" or "cPickle" + DUO103 + # argument name 'X' should be lowercase + N803, + # variable 'X' in function should be lowercase + N806, + # String literal formatting using f-string. + SFS3, + # Single letter variable names are not allowed + VNE001, + # TokenError: unterminated string literal + E902 per-file-ignores = large_scale_evaluation.py:T001 diff --git a/tasks.py b/tasks.py index be2f0238..7518824c 100644 --- a/tasks.py +++ b/tasks.py @@ -146,7 +146,7 @@ def lint(c): c.run('pydocstyle copulas') c.run('flake8 tests --ignore=D,SFS2') c.run('pydocstyle tests') - c.run('isort -c --recursive copulas tests') + c.run('isort -c copulas tests') def remove_readonly(func, path, _): diff --git a/tests/unit/multivariate/test_tree.py b/tests/unit/multivariate/test_tree.py index 72ef649e..53aff016 100644 --- a/tests/unit/multivariate/test_tree.py +++ b/tests/unit/multivariate/test_tree.py @@ -263,7 +263,7 @@ def test_first_tree(self): """Assert 0 is the center node on the first tree.""" assert self.tree.edges[0].L == 0 - @pytest.mark.xfail() + @pytest.mark.xfail def test_first_tree_likelihood(self): """Assert first tree likehood is correct.""" uni_matrix = np.array([[0.1, 0.2, 0.3, 0.4]]) @@ -288,7 +288,7 @@ def test_get_tau_matrix(self): assert not test.all() - @pytest.mark.xfail() + @pytest.mark.xfail def test_second_tree_likelihood(self): """Assert second tree likelihood is correct.""" # Setup @@ -350,7 +350,7 @@ def test_first_tree(self): assert sorted_edges[2].L == 2 assert sorted_edges[2].R == 3 - @pytest.mark.xfail() + @pytest.mark.xfail def test_first_tree_likelihood(self): """ Assert first tree likehood is correct""" uni_matrix = np.array([[0.1, 0.2, 0.3, 0.4]]) @@ -407,7 +407,7 @@ def test_first_tree(self): """ Assert 0 is the center node""" assert self.tree.edges[0].L == 0 - @pytest.mark.xfail() + @pytest.mark.xfail def test_first_tree_likelihood(self): """ Assert first tree likehood is correct""" uni_matrix = np.array([[0.1, 0.2, 0.3, 0.4]]) @@ -444,7 +444,7 @@ def test_get_tau_matrix(self): assert bool(test.all()) is False - @pytest.mark.xfail() + @pytest.mark.xfail def test_second_tree_likelihood(self): """Assert second tree likelihood is correct.""" tau = self.tree.get_tau_matrix() diff --git a/tests/unit/test___init__.py b/tests/unit/test___init__.py index 0d21a303..acd216f7 100644 --- a/tests/unit/test___init__.py +++ b/tests/unit/test___init__.py @@ -426,7 +426,7 @@ def test_get_instance_with_kwargs(self): assert instance.distribution == 'copulas.univariate.truncnorm.TruncNorm' -@pytest.fixture() +@pytest.fixture def mock_copulas(): copulas_module = sys.modules['copulas'] copulas_mock = MagicMock() @@ -479,7 +479,7 @@ def entry_point_error(): bad_entry_point = MagicMock() bad_entry_point.name = 'bad_entry_point' - bad_entry_point.module_name = 'bad_module' + bad_entry_point.version = 'bad_module' bad_entry_point.load.side_effect = entry_point_error entry_points_mock.return_value = [bad_entry_point] msg = 'Failed to load "bad_entry_point" from "bad_module".'