Skip to content

STYLE use pandas-dev-flaker #40906

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

Merged
merged 10 commits into from
Apr 16, 2021
Prev Previous commit
Next Next commit
better error message
  • Loading branch information
MarcoGorelli committed Apr 13, 2021
commit 8a0f453e1e58ee1539d8c08dd4e19a0bbf395b6c
8 changes: 4 additions & 4 deletions scripts/sync_flake8_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ def _validate_additional_dependencies(
for dep in flake8_additional_dependencies:
if dep not in yesqa_additional_dependencies:
sys.stdout.write(
f"Additional depedency of 'flake8' '{dep.name}' "
"does not match in 'yesqa'"
f"Mismatch of '{dep.name}' version between 'flake8' "
"and 'yesqa' in '.pre-commit-config.yaml'\n"
)
sys.exit(1)
if dep not in environment_additional_dependencies:
sys.stdout.write(
f"Additional depedency of 'flake8' '{dep.name}' "
"does not match in 'environment.yml'"
f"Mismatch of '{dep.name}' version between 'enviroment.yml' "
"and additional dependencies of 'flake8' in '.pre-commit-config.yaml'\n"
)
sys.exit(1)

Expand Down
40 changes: 9 additions & 31 deletions scripts/tests/test_sync_flake8_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from ..sync_flake8_versions import get_revisions


def test_wrong_yesqa(capsys):
def test_wrong_yesqa_flake8(capsys):
precommit_config = {
"repos": [
{
Expand All @@ -12,7 +12,6 @@ def test_wrong_yesqa(capsys):
"hooks": [
{
"id": "flake8",
"additional_dependencies": ["pandas-dev-flaker==0.2.0"],
}
],
},
Expand All @@ -24,7 +23,6 @@ def test_wrong_yesqa(capsys):
"id": "yesqa",
"additional_dependencies": [
"flake8==0.4.2",
"pandas-dev-flaker==0.2.1",
],
}
],
Expand All @@ -43,7 +41,7 @@ def test_wrong_yesqa(capsys):
assert result == expected


def test_wrong_env(capsys):
def test_wrong_env_flake8(capsys):
precommit_config = {
"repos": [
{
Expand All @@ -52,7 +50,6 @@ def test_wrong_env(capsys):
"hooks": [
{
"id": "flake8",
"additional_dependencies": ["pandas-dev-flaker==0.2.0"],
}
],
},
Expand All @@ -64,7 +61,6 @@ def test_wrong_env(capsys):
"id": "yesqa",
"additional_dependencies": [
"flake8==0.4.2",
"pandas-dev-flaker==0.2.1",
],
}
],
Expand All @@ -74,12 +70,6 @@ def test_wrong_env(capsys):
environment = {
"dependencies": [
"flake8=1.5.6",
{
"pip": [
"git+https://github.com/pydata/pydata-sphinx-theme.git@master",
"pandas-dev-flaker>=0.2.2",
]
},
]
}
with pytest.raises(SystemExit, match=None):
Expand All @@ -91,7 +81,7 @@ def test_wrong_env(capsys):
assert result == expected


def test_get_revisions_yesqa_failure(capsys):
def test_wrong_yesqa_add_dep(capsys):
precommit_config = {
"repos": [
{
Expand All @@ -101,7 +91,6 @@ def test_get_revisions_yesqa_failure(capsys):
{
"id": "flake8",
"additional_dependencies": [
"pandas-dev-flaker==0.2.0",
"flake8-bugs==1.1.1",
],
}
Expand All @@ -115,7 +104,6 @@ def test_get_revisions_yesqa_failure(capsys):
"id": "yesqa",
"additional_dependencies": [
"flake8==0.4.2",
"pandas-dev-flaker==0.2.1",
"flake8-bugs>=1.1.1",
],
}
Expand All @@ -127,23 +115,19 @@ def test_get_revisions_yesqa_failure(capsys):
"dependencies": [
"flake8=1.5.6",
"flake8-bugs=1.1.1",
{
"pip": [
"pandas-dev-flaker>=0.2.2",
]
},
]
}
with pytest.raises(SystemExit, match=None):
get_revisions(precommit_config, environment)
result, _ = capsys.readouterr()
expected = (
"Additional depedency of 'flake8' 'flake8-bugs' does not match in 'yesqa'"
"Mismatch of 'flake8-bugs' version between 'flake8' and 'yesqa' in "
"'.pre-commit-config.yaml'\n"
)
assert result == expected


def test_get_revisions_env_failure(capsys):
def test_wrong_env_add_dep(capsys):
precommit_config = {
"repos": [
{
Expand All @@ -153,7 +137,6 @@ def test_get_revisions_env_failure(capsys):
{
"id": "flake8",
"additional_dependencies": [
"pandas-dev-flaker==0.2.0",
"flake8-bugs==1.1.1",
],
}
Expand All @@ -167,7 +150,6 @@ def test_get_revisions_env_failure(capsys):
"id": "yesqa",
"additional_dependencies": [
"flake8==0.4.2",
"pandas-dev-flaker==0.2.1",
"flake8-bugs==1.1.1",
],
}
Expand All @@ -179,19 +161,14 @@ def test_get_revisions_env_failure(capsys):
"dependencies": [
"flake8=1.5.6",
"flake8-bugs=1.1.2",
{
"pip": [
"pandas-dev-flaker>=0.2.3",
]
},
]
}
with pytest.raises(SystemExit, match=None):
get_revisions(precommit_config, environment)
result, _ = capsys.readouterr()
expected = (
"Additional depedency of 'flake8' 'flake8-bugs' does not "
"match in 'environment.yml'"
"Mismatch of 'flake8-bugs' version between 'enviroment.yml' "
"and additional dependencies of 'flake8' in '.pre-commit-config.yaml'\n"
)
assert result == expected

Expand Down Expand Up @@ -234,6 +211,7 @@ def test_get_revisions_no_failure(capsys):
"flake8-bugs=1.1.1",
{
"pip": [
"git+https://github.com/pydata/pydata-sphinx-theme.git@master",
"pandas-dev-flaker==0.2.0",
]
},
Expand Down