This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 11f732c7d0 Add a bit more PT rules (#37827)
11f732c7d0 is described below
commit 11f732c7d081851796418a95ad5556dccab8b6b1
Author: Andrey Anshin <[email protected]>
AuthorDate: Fri Mar 1 21:04:59 2024 +0400
Add a bit more PT rules (#37827)
---
pyproject.toml | 22 ++++++++++++----------
.../providers/cncf/kubernetes/triggers/test_pod.py | 3 +--
.../transfers/test_copy_into_snowflake.py | 4 ++--
tests/system/providers/papermill/conftest.py | 3 ++-
4 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index c2ab183ea7..9765b31dbb 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1310,6 +1310,7 @@ extend-select = [
"TCH", # Rules around TYPE_CHECKING blocks
"G", # flake8-logging-format rules
"LOG", # flake8-logging rules, most of them autofixable
+ "PT", # flake8-pytest-style rules
# Per rule enables
"RUF100", # Unused noqa (auto-fixable)
# We ignore more pydocstyle than we enable, so be more selective at what
we enable
@@ -1330,16 +1331,6 @@ extend-select = [
"TID251", # Specific modules or module members that may not be imported
or accessed
"TID253", # Ban certain modules from being imported at module level
"B006", # Checks for uses of mutable objects as function argument defaults.
- "PT001",
- "PT003",
- "PT009",
- "PT014", # Checks for duplicate test cases in pytest.mark.parametrize
- "PT022",
- "PT023",
- "PT024",
- "PT025",
- "PT026",
- "PT027",
]
ignore = [
"G003", # Logging statement uses + (not fixed yet)
@@ -1351,6 +1342,17 @@ ignore = [
"D215",
"E731",
"TCH003", # Do not move imports from stdlib to TYPE_CHECKING block
+ "PT004", # Fixture does not return anything, add leading underscore
+ "PT005", # Fixture returns a value, remove leading underscore
+ "PT006", # Wrong type of names in @pytest.mark.parametrize
+ "PT007", # Wrong type of values in @pytest.mark.parametrize
+ "PT008", # Use return_value= instead of patching with lambda
+ "PT011", # pytest.raises() is too broad, set the match parameter
+ "PT012", # [controversial rule] pytest.raises() block should contain a
single simple statement.
+ "PT015", # assertion always fails, replace with pytest.fail()
+ "PT017", # raise exception in except block, use pytest.raises() instead
+ "PT018", # assertion should be broken down into multiple parts
+ "PT019", # fixture without value is injected as parameter, use
@pytest.mark.usefixtures instead
]
unfixable = [
# PT022 replace empty `yield` to empty `return`. Might be fixed with a
combination of PLR1711
diff --git a/tests/providers/cncf/kubernetes/triggers/test_pod.py
b/tests/providers/cncf/kubernetes/triggers/test_pod.py
index ef06ff3c0a..93b1da5c92 100644
--- a/tests/providers/cncf/kubernetes/triggers/test_pod.py
+++ b/tests/providers/cncf/kubernetes/triggers/test_pod.py
@@ -27,7 +27,6 @@ from unittest.mock import MagicMock
import pytest
from kubernetes.client import models as k8s
from pendulum import DateTime
-from pytest import param
from airflow.providers.cncf.kubernetes.triggers.pod import ContainerState,
KubernetesPodTrigger
from airflow.providers.cncf.kubernetes.utils.pod_manager import PodPhase
@@ -239,7 +238,7 @@ class TestKubernetesPodTrigger:
@pytest.mark.parametrize(
"logging_interval, exp_event",
[
- param(
+ pytest.param(
0,
{
"status": "running",
diff --git a/tests/providers/snowflake/transfers/test_copy_into_snowflake.py
b/tests/providers/snowflake/transfers/test_copy_into_snowflake.py
index 27e02dc41c..220de18c2b 100644
--- a/tests/providers/snowflake/transfers/test_copy_into_snowflake.py
+++ b/tests/providers/snowflake/transfers/test_copy_into_snowflake.py
@@ -19,6 +19,7 @@ from __future__ import annotations
from typing import Callable
from unittest import mock
+import pytest
from openlineage.client.facet import (
ExternalQueryRunFacet,
ExtractionError,
@@ -26,7 +27,6 @@ from openlineage.client.facet import (
SqlJobFacet,
)
from openlineage.client.run import Dataset
-from pytest import mark
from airflow.providers.openlineage.extractors import OperatorLineage
from airflow.providers.openlineage.sqlparser import DatabaseInfo
@@ -131,7 +131,7 @@ class TestCopyFromExternalStageToSnowflake:
job_facets={"sql": SqlJobFacet(query=expected_sql)},
)
- @mark.parametrize("rows", (None, []))
+ @pytest.mark.parametrize("rows", (None, []))
@mock.patch("airflow.providers.snowflake.transfers.copy_into_snowflake.SnowflakeHook")
def test_get_openlineage_facets_on_complete_with_empty_inputs(self,
mock_hook, rows):
mock_hook().run.return_value = rows
diff --git a/tests/system/providers/papermill/conftest.py
b/tests/system/providers/papermill/conftest.py
index 4594c13e84..98aa6ef8bb 100644
--- a/tests/system/providers/papermill/conftest.py
+++ b/tests/system/providers/papermill/conftest.py
@@ -46,7 +46,8 @@ def remote_kernel(request):
"--ip=0.0.0.0",
]
)
- request.addfinalizer(proc.kill)
+ yield
+ proc.kill()
@pytest.fixture(scope="session", autouse=True)