pytest-csv-params 2.1.1__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/.gitignore +6 -0
  2. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/PKG-INFO +27 -5
  3. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/README.md +26 -4
  4. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/parametrize.py +30 -31
  5. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/varname.py +1 -4
  6. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/version.py +6 -10
  7. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pyproject.toml +60 -7
  8. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/types.py +17 -10
  9. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/LICENSE.txt +0 -0
  10. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/__init__.py +0 -0
  11. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/cmdline.py +0 -0
  12. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/configure.py +0 -0
  13. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/exception.py +0 -0
  14. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/_ptcsvp/plugin.py +0 -0
  15. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/__init__.py +0 -0
  16. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/decorator.py +0 -0
  17. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/dialect.py +0 -0
  18. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/exception.py +0 -0
  19. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/plugin.py +0 -0
  20. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/shortcut.py +0 -0
  21. {pytest_csv_params-2.1.1 → pytest_csv_params-2.2.2}/pytest_csv_params/warning.py +0 -0
@@ -232,3 +232,9 @@ fabric.properties
232
232
 
233
233
  # Android studio 3.1+ serialized cache file
234
234
  .idea/caches/build_file_checksums.ser
235
+
236
+ # Python formatter
237
+ .ruff-cache/
238
+
239
+ # Working on a Mac?
240
+ .DS_Store
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pytest-csv-params
3
- Version: 2.1.1
3
+ Version: 2.2.2
4
4
  Summary: Pytest plugin for Test Case Parametrization with CSV files
5
5
  Project-URL: repository, https://git.codebau.dev/pytest-plugins/pytest-csv-params
6
6
  Project-URL: homepage, https://git.codebau.dev/pytest-plugins/pytest-csv-params
@@ -34,12 +34,14 @@ Requires-Python: <3.16,>=3.10
34
34
  Requires-Dist: pytest<10,>=8.3
35
35
  Description-Content-Type: text/markdown
36
36
 
37
- ![pytest-csv-params](https://docs.codebau.dev/pytest-plugins/pytest-csv-params/_images/pytest-csv-params.png)
37
+ from typing import Dict![pytest-csv-params](https://docs.codebau.dev/pytest-plugins/pytest-csv-params/_images/pytest-csv-params.png)
38
38
 
39
39
  # pytest-csv-params
40
40
 
41
41
  A pytest plugin to parametrize data-driven tests by CSV files.
42
42
 
43
+ ![CI Pipeline Build Status](https://build.codebau.dev/buildStatus/icon?job=pytest-csv-params&subject=CI+Pipeline)
44
+ ![Carnary Build Status](https://build.codebau.dev/buildStatus/icon?job=pytest-csv-params_canary&subject=Carnary+Build)
43
45
  [![PyPI - Downloads](https://img.shields.io/pypi/dw/pytest-csv-params?label=PyPI%20downloads&style=flat&logo=pypi)](https://pypi.org/project/pytest-csv-params/)
44
46
  [![PyPI - Version](https://img.shields.io/pypi/v/pytest-csv-params?label=PyPI%20version&style=flat&logo=pypi)](https://pypi.org/project/pytest-csv-params/)
45
47
  [![PyPI - Status](https://img.shields.io/pypi/status/pytest-csv-params?label=PyPI%20status&style=flat&logo=pypi)](https://pypi.org/project/pytest-csv-params/)
@@ -100,6 +102,7 @@ Simply decorate your test method with `@csv_params` (`pytest_csv_params.decorato
100
102
  | `reuse_id_col` | `bool` (optional) | Allows to re-use the ID column as test data column (since 1.3.0), defaults to `False` for backwards compatibility | `True` |
101
103
  | `skip_when_missing_csv_file` | `bool` (optional) | When the CSV data cannot be loaded, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
102
104
  | `skip_when_empty_csv_file` | `bool` (optional) | When the CSV data file is empty, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
105
+ | `parameters_as_dictionary` | `str` (optional) | Instead of using one method argument per column, all columns are provided in the dict named with this parameter (since 2.2.0) | `test_data` |
103
106
 
104
107
  ## CSV Format
105
108
 
@@ -117,6 +120,7 @@ This example uses the CSV example from above.
117
120
  ```python
118
121
  from pytest_csv_params.decorator import csv_params
119
122
 
123
+
120
124
  @csv_params(
121
125
  data_file="/data/test-lib/cases/addition.csv",
122
126
  id_col="ID#",
@@ -135,11 +139,26 @@ Shorthand example (no ID col, only string values):
135
139
  ```python
136
140
  from pytest_csv_params.decorator import csv_params
137
141
 
142
+
138
143
  @csv_params("/data/test-lib/cases/texts.csv")
139
144
  def test_texts(text_a, text_b, text_c):
140
145
  assert f"{text_a}:{text_b}" == text_c
141
146
  ```
142
147
 
148
+ Use a dictionary instead of multiple arguments:
149
+
150
+ ```python
151
+ from pytest_csv_params.decorator import csv_params
152
+
153
+
154
+ @csv_params(
155
+ data_file="/data/test-lib/cases/texts.csv",
156
+ parameters_as_dictionary="test_data",
157
+ )
158
+ def test_texts(test_data: dict):
159
+ assert f"{test_data['text_a']}:{test_data['text_b']}" == test_data["text_c"]
160
+ ```
161
+
143
162
  ### More complex example
144
163
 
145
164
  This example features nearly all things the plugin has to offer. You find this example also in the test cases, see `tests/test_complex_example.py`.
@@ -207,9 +226,12 @@ If you decide not to rename the columns, the test would look like this:
207
226
  },
208
227
  )
209
228
  def test_container_size_is_big_enough(
210
- Bananas_Shipped: int, Single_Banana_Weight: float, Apples_Shipped: int, Single_Apple_Weight: float, Container_Size: int
211
- ) -> None:
212
- ...
229
+ Bananas_Shipped: int,
230
+ Single_Banana_Weight: float,
231
+ Apples_Shipped: int,
232
+ Single_Apple_Weight: float,
233
+ Container_Size: int,
234
+ ) -> None: ...
213
235
  ```
214
236
 
215
237
  ## Changelog
@@ -1,9 +1,11 @@
1
- ![pytest-csv-params](https://docs.codebau.dev/pytest-plugins/pytest-csv-params/_images/pytest-csv-params.png)
1
+ from typing import Dict![pytest-csv-params](https://docs.codebau.dev/pytest-plugins/pytest-csv-params/_images/pytest-csv-params.png)
2
2
 
3
3
  # pytest-csv-params
4
4
 
5
5
  A pytest plugin to parametrize data-driven tests by CSV files.
6
6
 
7
+ ![CI Pipeline Build Status](https://build.codebau.dev/buildStatus/icon?job=pytest-csv-params&subject=CI+Pipeline)
8
+ ![Carnary Build Status](https://build.codebau.dev/buildStatus/icon?job=pytest-csv-params_canary&subject=Carnary+Build)
7
9
  [![PyPI - Downloads](https://img.shields.io/pypi/dw/pytest-csv-params?label=PyPI%20downloads&style=flat&logo=pypi)](https://pypi.org/project/pytest-csv-params/)
8
10
  [![PyPI - Version](https://img.shields.io/pypi/v/pytest-csv-params?label=PyPI%20version&style=flat&logo=pypi)](https://pypi.org/project/pytest-csv-params/)
9
11
  [![PyPI - Status](https://img.shields.io/pypi/status/pytest-csv-params?label=PyPI%20status&style=flat&logo=pypi)](https://pypi.org/project/pytest-csv-params/)
@@ -64,6 +66,7 @@ Simply decorate your test method with `@csv_params` (`pytest_csv_params.decorato
64
66
  | `reuse_id_col` | `bool` (optional) | Allows to re-use the ID column as test data column (since 1.3.0), defaults to `False` for backwards compatibility | `True` |
65
67
  | `skip_when_missing_csv_file` | `bool` (optional) | When the CSV data cannot be loaded, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
66
68
  | `skip_when_empty_csv_file` | `bool` (optional) | When the CSV data file is empty, the test will be skipped (since 2.1.0), defaults to `False` for backwards compatibility | `True` |
69
+ | `parameters_as_dictionary` | `str` (optional) | Instead of using one method argument per column, all columns are provided in the dict named with this parameter (since 2.2.0) | `test_data` |
67
70
 
68
71
  ## CSV Format
69
72
 
@@ -81,6 +84,7 @@ This example uses the CSV example from above.
81
84
  ```python
82
85
  from pytest_csv_params.decorator import csv_params
83
86
 
87
+
84
88
  @csv_params(
85
89
  data_file="/data/test-lib/cases/addition.csv",
86
90
  id_col="ID#",
@@ -99,11 +103,26 @@ Shorthand example (no ID col, only string values):
99
103
  ```python
100
104
  from pytest_csv_params.decorator import csv_params
101
105
 
106
+
102
107
  @csv_params("/data/test-lib/cases/texts.csv")
103
108
  def test_texts(text_a, text_b, text_c):
104
109
  assert f"{text_a}:{text_b}" == text_c
105
110
  ```
106
111
 
112
+ Use a dictionary instead of multiple arguments:
113
+
114
+ ```python
115
+ from pytest_csv_params.decorator import csv_params
116
+
117
+
118
+ @csv_params(
119
+ data_file="/data/test-lib/cases/texts.csv",
120
+ parameters_as_dictionary="test_data",
121
+ )
122
+ def test_texts(test_data: dict):
123
+ assert f"{test_data['text_a']}:{test_data['text_b']}" == test_data["text_c"]
124
+ ```
125
+
107
126
  ### More complex example
108
127
 
109
128
  This example features nearly all things the plugin has to offer. You find this example also in the test cases, see `tests/test_complex_example.py`.
@@ -171,9 +190,12 @@ If you decide not to rename the columns, the test would look like this:
171
190
  },
172
191
  )
173
192
  def test_container_size_is_big_enough(
174
- Bananas_Shipped: int, Single_Banana_Weight: float, Apples_Shipped: int, Single_Apple_Weight: float, Container_Size: int
175
- ) -> None:
176
- ...
193
+ Bananas_Shipped: int,
194
+ Single_Banana_Weight: float,
195
+ Apples_Shipped: int,
196
+ Single_Apple_Weight: float,
197
+ Container_Size: int,
198
+ ) -> None: ...
177
199
  ```
178
200
 
179
201
  ## Changelog
@@ -4,13 +4,13 @@ Parametrize a test function by CSV file
4
4
 
5
5
  import csv
6
6
  from pathlib import Path
7
- from typing import Any, List, Optional, TypedDict
7
+ from typing import Any, TypedDict
8
8
  from warnings import warn
9
9
 
10
10
  import pytest
11
11
  from _pytest.mark import MarkDecorator
12
12
 
13
- from _ptcsvp.plugin import BASE_DIR_KEY, Plugin, SKIP_MISSING_KEY, SKIP_EMPTY_KEY
13
+ from _ptcsvp.plugin import BASE_DIR_KEY, SKIP_EMPTY_KEY, SKIP_MISSING_KEY, Plugin
14
14
  from _ptcsvp.varname import make_name_valid
15
15
  from pytest_csv_params.dialect import CsvParamsDefaultDialect
16
16
  from pytest_csv_params.exception import (
@@ -24,6 +24,7 @@ from pytest_csv_params.types import (
24
24
  CsvDialect,
25
25
  DataCasts,
26
26
  DataFile,
27
+ DictionaryName,
27
28
  HeaderRenames,
28
29
  IdColName,
29
30
  SkipConfig,
@@ -36,13 +37,11 @@ class TestCaseParameters(TypedDict):
36
37
  Type for a single test case. Contains the optional :attr:`test_id` and the test :attr:`data`.
37
38
  """
38
39
 
39
- test_id: Optional[str]
40
- data: List[Any]
40
+ test_id: str | None
41
+ data: list[Any]
41
42
 
42
43
 
43
- def read_csv(
44
- base_dir: BaseDir, data_file: DataFile, dialect: CsvDialect
45
- ) -> List[List[str]]:
44
+ def read_csv(base_dir: BaseDir, data_file: DataFile, dialect: CsvDialect) -> list[list[str]]:
46
45
  """
47
46
  Get Data from CSV
48
47
 
@@ -57,27 +56,23 @@ def read_csv(
57
56
  if data_file is None:
58
57
  raise CsvParamsDataFileInvalid("Data file is None") from None
59
58
  csv_file = Path(data_file)
60
- if not csv_file.is_absolute():
61
- if base_dir is not None:
62
- csv_file = Path(base_dir) / csv_file
59
+ if not csv_file.is_absolute() and base_dir is not None:
60
+ csv_file = Path(base_dir) / csv_file
63
61
  if not csv_file.exists() or not csv_file.is_file():
64
- raise CsvParamsDataFileNotFound(f"Cannot find file: {str(csv_file)}") from None
62
+ raise CsvParamsDataFileNotFound(f"Cannot find file: {csv_file!s}") from None
65
63
  csv_lines = []
66
64
  try:
67
65
  with open(csv_file, newline="", encoding="utf-8") as csv_file_handle:
68
66
  csv_reader = csv.reader(csv_file_handle, dialect=dialect)
69
- for row in csv_reader:
70
- csv_lines.append(row)
71
- except IOError as err: # pragma: no cover
72
- raise CsvParamsDataFileInaccessible(
73
- f"Unable to read file: {str(csv_file)}"
74
- ) from err
67
+ csv_lines.extend(csv_reader)
68
+ except OSError as err: # pragma: no cover
69
+ raise CsvParamsDataFileInaccessible(f"Unable to read file: {csv_file!s}") from err
75
70
  except csv.Error as err:
76
71
  raise CsvParamsDataFileInvalid("Invalid data") from err
77
72
  return csv_lines
78
73
 
79
74
 
80
- def clean_headers(current_headers: List[str], replacing: HeaderRenames) -> List[str]:
75
+ def clean_headers(current_headers: list[str], replacing: HeaderRenames) -> list[str]:
81
76
  """
82
77
  Clean the CSV file headers
83
78
 
@@ -110,6 +105,7 @@ def add_parametrization( # pylint: disable=too-many-arguments
110
105
  reuse_id_col: bool = False,
111
106
  skip_when_missing_csv_file: SkipConfig = None,
112
107
  skip_when_empty_csv_file: SkipConfig = None,
108
+ parameters_as_dictionary: DictionaryName = None,
113
109
  ) -> MarkDecorator:
114
110
  """
115
111
  Parametrize a test function with data from a CSV file.
@@ -125,6 +121,7 @@ def add_parametrization( # pylint: disable=too-many-arguments
125
121
  :param reuse_id_col: Allows re-using the ID col as test data column; defaults to `False` for backwards compatibility
126
122
  :param skip_when_missing_csv_file: Let tests automatically skip when CSV source is missing (since 2.1.0)
127
123
  :param skip_when_empty_csv_file: Let tests automatically skip when CSV source does not contain any test data (since 2.1.0)
124
+ :param parameters_as_dictionary: Instead of using one argument per field, all arguments are passed as a dictionary with the given name (since 2.2.0)
128
125
 
129
126
  :returns: :meth:`pytest.mark.parametrize` mark decorator, filled with all the data from the CSV.
130
127
  """
@@ -138,18 +135,12 @@ def add_parametrization( # pylint: disable=too-many-arguments
138
135
  csv_lines = read_csv(base_dir, data_file, dialect)
139
136
  except (CsvParamsDataFileNotFound, CsvParamsDataFileInaccessible):
140
137
  if skip_when_missing_csv_file:
141
- return pytest.mark.skip(
142
- reason=f"CSV file '{data_file}' not found, test needs to be skipped"
143
- )
138
+ return pytest.mark.skip(reason=f"CSV file '{data_file}' not found, test needs to be skipped")
144
139
  raise
145
140
  if len(csv_lines) < 2:
146
141
  if skip_when_empty_csv_file:
147
- return pytest.mark.skip(
148
- reason=f"CSV file '{data_file}' has no test data in it, test needs to be skipped"
149
- )
150
- raise CsvParamsDataFileInvalid(
151
- "File does not contain a single data row"
152
- ) from None
142
+ return pytest.mark.skip(reason=f"CSV file '{data_file}' has no test data in it, test needs to be skipped")
143
+ raise CsvParamsDataFileInvalid("File does not contain a single data row") from None
153
144
  id_index = -1
154
145
  headers = csv_lines.pop(0)
155
146
  if id_col is not None:
@@ -168,7 +159,7 @@ def add_parametrization( # pylint: disable=too-many-arguments
168
159
  CsvParamsOnlyOneColumnIsUsedAsIdAndDataWarning,
169
160
  )
170
161
  headers = clean_headers(headers, header_renames)
171
- data: List[TestCaseParameters] = []
162
+ data: list[TestCaseParameters] = []
172
163
  for data_line in csv_lines:
173
164
  line = list(map(str, data_line))
174
165
  if len(line) == 0:
@@ -195,6 +186,14 @@ def add_parametrization( # pylint: disable=too-many-arguments
195
186
  id_data = None
196
187
  if id_col is not None:
197
188
  id_data = [tc_data["test_id"] for tc_data in data]
198
- return pytest.mark.parametrize(
199
- headers, [tc_data["data"] for tc_data in data], ids=id_data
200
- )
189
+ if parameters_as_dictionary is not None:
190
+ param_header_name = make_name_valid(parameters_as_dictionary)
191
+ list_of_dicts: list[dict[str, Any]] = []
192
+ for tc_element in [tc_data["data"] for tc_data in data]:
193
+ list_of_dicts.append(dict(zip(headers, tc_element)))
194
+ return pytest.mark.parametrize(
195
+ param_header_name,
196
+ [pytest.param(d) for d in list_of_dicts],
197
+ ids=id_data,
198
+ )
199
+ return pytest.mark.parametrize(headers, [tc_data["data"] for tc_data in data], ids=id_data)
@@ -29,10 +29,7 @@ def is_valid_name(name: str) -> bool:
29
29
  """
30
30
  if (
31
31
  keyword.iskeyword(name)
32
- or (
33
- hasattr(keyword, "issoftkeyword")
34
- and getattr(keyword, "issoftkeyword")(name)
35
- )
32
+ or (hasattr(keyword, "issoftkeyword") and keyword.issoftkeyword(name))
36
33
  or getattr(builtins, name, None) is not None
37
34
  ):
38
35
  return False
@@ -6,13 +6,13 @@ During the setup phase of the plugin (see :mod:`pytest_csv_params.plugin`) these
6
6
  """
7
7
 
8
8
  import sys
9
- from typing import Tuple
10
9
 
11
- from .exception import PythonVersionTooOldException, PytestVersionTooOldException
12
10
  from packaging.version import parse
13
11
 
12
+ from .exception import PytestVersionTooOldException, PythonVersionTooOldException
14
13
 
15
- def check_python_version(min_version: Tuple[int, int] = (3, 10)) -> None:
14
+
15
+ def check_python_version(min_version: tuple[int, int] = (3, 10)) -> None:
16
16
  """
17
17
  Check if the current version is at least 3.10
18
18
 
@@ -21,12 +21,10 @@ def check_python_version(min_version: Tuple[int, int] = (3, 10)) -> None:
21
21
  """
22
22
 
23
23
  if sys.version_info < min_version:
24
- raise PythonVersionTooOldException(
25
- f"At least Python {'.'.join(map(str, min_version))} required"
26
- )
24
+ raise PythonVersionTooOldException(f"At least Python {'.'.join(map(str, min_version))} required")
27
25
 
28
26
 
29
- def check_pytest_version(min_version: Tuple[int, int] = (8, 3)) -> None:
27
+ def check_pytest_version(min_version: tuple[int, int] = (8, 3)) -> None:
30
28
  """
31
29
  Check if the current version is at least 8.3
32
30
 
@@ -40,6 +38,4 @@ def check_pytest_version(min_version: Tuple[int, int] = (8, 3)) -> None:
40
38
  parsed_min_version = parse(pytest_min_version)
41
39
  parsed_actual_version = parse(pytest_version)
42
40
  if parsed_actual_version < parsed_min_version:
43
- raise PytestVersionTooOldException(
44
- f"At least Pytest {pytest_min_version} required"
45
- )
41
+ raise PytestVersionTooOldException(f"At least Pytest {pytest_min_version} required")
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pytest-csv-params"
3
- version = "2.1.1"
3
+ version = "2.2.2"
4
4
  description = "Pytest plugin for Test Case Parametrization with CSV files"
5
5
  authors = [
6
6
  { name = "Juergen Edelbluth", email = "csv_params@jued.de" },
@@ -43,6 +43,7 @@ dev = [
43
43
  "pytest-mock (>=3.16.0,<4.0.0)",
44
44
  "pytest-clarity>=1.0.1",
45
45
  "pytest-order>=1.0.1",
46
+ "ruff>=0.16.10",
46
47
  ]
47
48
 
48
49
  docs = [
@@ -82,12 +83,6 @@ junit_log_passing_tests = true
82
83
  junit_duration_report = "call"
83
84
  junit_suite_name = "pytest-csv-params"
84
85
 
85
- bandit_targets = [
86
- "pytest_csv_params",
87
- "_ptcsvp",
88
- ]
89
- bandit_recurse = "True"
90
-
91
86
  [tool.coverage]
92
87
 
93
88
  [tool.coverage.run]
@@ -156,3 +151,61 @@ only-include = [
156
151
  "_ptcsvp",
157
152
  "pytest_csv_params",
158
153
  ]
154
+ [tool.ruff]
155
+ # Exclude a variety of commonly ignored directories.
156
+ extend-exclude = [
157
+ ".ci",
158
+ ".junie",
159
+ ".venv",
160
+ "dist",
161
+ "docs",
162
+ "*.egg-info",
163
+ "test-reports",
164
+ ".coverage",
165
+ ".*_cacne",
166
+ ]
167
+
168
+ # Same as Black.
169
+ line-length = 120
170
+ indent-width = 4
171
+
172
+ # Assume Python 3.10
173
+ target-version = "py310"
174
+
175
+ [tool.ruff.lint]
176
+ # select = [...] # See the Default Rules page for the full listing.
177
+ ignore = []
178
+
179
+ # Allow fix for all enabled rules (when `--fix`) is provided.
180
+ fixable = ["ALL"]
181
+ unfixable = []
182
+
183
+ # Allow unused variables when underscore-prefixed.
184
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
185
+
186
+ [tool.ruff.format]
187
+ # Like Black, use double quotes for strings.
188
+ quote-style = "double"
189
+
190
+ # Like Black, indent with spaces, rather than tabs.
191
+ indent-style = "space"
192
+
193
+ # Like Black, respect magic trailing commas.
194
+ skip-magic-trailing-comma = false
195
+
196
+ # Like Black, automatically detect the appropriate line ending.
197
+ line-ending = "auto"
198
+
199
+ # Enable auto-formatting of code examples in docstrings. Markdown,
200
+ # reStructuredText code/literal blocks and doctests are all supported.
201
+ #
202
+ # This is currently disabled by default, but it is planned for this
203
+ # to be opt-out in the future.
204
+ docstring-code-format = true
205
+
206
+ # Set the line length limit used when formatting code snippets in
207
+ # docstrings.
208
+ #
209
+ # This only has an effect when the `docstring-code-format` setting is
210
+ # enabled.
211
+ docstring-code-line-length = "dynamic"
@@ -5,7 +5,8 @@ Some types are somewhat complex, and it is easier to use a single word/reference
5
5
  """
6
6
 
7
7
  import csv
8
- from typing import Any, Callable, Dict, Optional, Type
8
+ from collections.abc import Callable
9
+ from typing import Any
9
10
 
10
11
  DataCast = Callable[[str], Any]
11
12
  """
@@ -13,26 +14,26 @@ A :class:`DataCast` describes how a data casting callable must be implemented. I
13
14
  :class:`str` and can return anything that is required.
14
15
  """
15
16
 
16
- DataCastDict = Dict[str, DataCast]
17
+ DataCastDict = dict[str, DataCast]
17
18
  """
18
19
  A :class:`DataCastDict` describes how a dictionary of data casting callables must look like. The key is a :class:`str`
19
20
  describing the column name, the value is a :class:`DataCast`.
20
21
  """
21
22
 
22
- DataCasts = Optional[DataCastDict]
23
+ DataCasts = DataCastDict | None
23
24
  """
24
25
  The :class:`DataCasts` type describes the type of the `data_casts` parameter of the
25
26
  :meth:`~pytest_csv_params.decorator.csv_params` decorator. An optional :class:`DataCastDict`.
26
27
  """
27
28
 
28
- BaseDir = Optional[str]
29
+ BaseDir = str | None
29
30
  """
30
31
  The :class:`BaseDir` describes the type of the `base_dir` parameter of the
31
32
  :meth:`~pytest_csv_params.decorator.csv_params` decorator to search for non-absolute CSV files. It is simply an optional
32
33
  :class:`str`.
33
34
  """
34
35
 
35
- IdColName = Optional[str]
36
+ IdColName = str | None
36
37
  """
37
38
  The :class:`IdColName` describes the type of the `id_col` parameter of the
38
39
  :meth:`~pytest_csv_params.decorator.csv_params` decorator to name the ID column from a CSV file. It is simply an
@@ -46,27 +47,33 @@ The :class:`DataFile` describes the type if the `data_file` parameter of the
46
47
  :class:`str`.
47
48
  """
48
49
 
49
- CsvDialect = Type[csv.Dialect]
50
+ CsvDialect = type[csv.Dialect]
50
51
  """
51
52
  The :class:`CsvDialect` describes the type of the `dialect` parameter of the
52
53
  :meth:`~pytest_csv_params.decorator.csv_params` decorator. It is required, but it has an default value in
53
54
  :class:`pytest_csv_params.dialect.CsvParamsDefaultDialect`.
54
55
  """
55
56
 
56
- HeaderRenamesDict = Dict[str, str]
57
+ HeaderRenamesDict = dict[str, str]
57
58
  """
58
59
  The :class:`HeaderRenamesDict` describes how a dictionary of header renames must look. Keys and values must both be of
59
60
  type :class:`str`.
60
61
  """
61
62
 
62
- HeaderRenames = Optional[HeaderRenamesDict]
63
+ HeaderRenames = HeaderRenamesDict | None
63
64
  """
64
65
  The :class:`HeaderRenames` describes the type of the `header_renames` parameter of the
65
66
  :meth:`~pytest_csv_params.decorator.csv_params` decorator. It is just an optional :class:`HeaderRenamesDict`.
66
67
  """
67
68
 
68
- SkipConfig = Optional[bool]
69
+ SkipConfig = bool | None
69
70
  """
70
- The :class:`SkipWhenMissingCSVFile` describes the type of the `skip_when_missing_csv_files` parameter of the
71
+ The :class:`SkipWhenMissingCSVFile` describes the type of the `skip_when_*_csv_files` parameter of the
71
72
  :meth:`~pytest_csv_params.decorator.csv_params` decorator. It is just an optional :class:`bool`.
72
73
  """
74
+
75
+ DictionaryName = str | None
76
+ """
77
+ The :class:`DictionaryName` describes the type of the `parameters_as_dictionary` parameter of the
78
+ :meth:`~pytest_csv_params.decorator.csv_params` decorator. It is just an optional :class:`str`.
79
+ """