Skip to content

Commit aae8ba7

Browse files
committed
chore: build fixes
1 parent 58d849d commit aae8ba7

8 files changed

Lines changed: 37 additions & 36 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ dist
1616
build
1717
tmp
1818

19+
src/robotframework_assertion_engine.egg-info
20+
1921
.ruff_cache
2022
.pytest_cache

pyproject.toml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,27 @@ description = "Generic way to create meaningful and easy to use assertions for t
55
authors = [{ name="Tatu Aalto", email="aalto.tatu@gmail.com" }]
66
license = "Apache-2.0"
77
readme = "README.md"
8+
classifiers = [
9+
"Programming Language :: Python :: 3",
10+
"Operating System :: OS Independent",
11+
]
812
keywords = ["Robot Framework", "Libraries", "Assertions"]
9-
10-
requires-python = ">=3.10,<4.0"
13+
requires-python = ">=3.10"
1114
dependencies = ["robotframework >= 6.1.1", "robotframework-pythonlibcore>=3.0.0"]
1215

1316
[project.urls]
1417
Homepage = "https://github.com/MarketSquare/AssertionEngine"
1518
Issues = "https://github.com/MarketSquare/AssertionEngine/issues"
1619
Changelog = "https://github.com/MarketSquare/AssertionEngine/releases"
1720

18-
[tool.setuptools]
19-
packages = ["assertionengine"]
20-
2121
[tool.ruff]
22-
lint.unfixable = []
2322
exclude = [
2423
"__pycache__",
2524
]
2625
lint.ignore = [
2726
"E501", # line too long
2827
]
29-
target-version = "py38"
28+
target-version = "py310"
3029
lint.select = [
3130
"E",
3231
"F",
Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
import ast
1616
import re
17+
from collections.abc import Callable
1718
from enum import Enum, Flag, IntFlag
18-
from typing import Any, Callable, Dict, List, Optional, Tuple, TypeVar, Union, cast
19+
from typing import Any, TypeVar, cast
1920

2021
from robot.libraries.BuiltIn import BuiltIn
2122

@@ -107,7 +108,7 @@
107108
AssertionOperator["then"],
108109
]
109110

110-
handlers: Dict[AssertionOperator, Tuple[Callable, str]] = {
111+
handlers: dict[AssertionOperator, tuple[Callable, str]] = {
111112
AssertionOperator["=="]: (lambda a, b: a == b, "should be"),
112113
AssertionOperator["!="]: (lambda a, b: a != b, "should not be"),
113114
AssertionOperator["<"]: (lambda a, b: a < b, "should be less than"),
@@ -132,7 +133,7 @@
132133
}
133134

134135

135-
set_handlers: Dict[AssertionOperator, Tuple[Callable, str]] = {
136+
set_handlers: dict[AssertionOperator, tuple[Callable, str]] = {
136137
AssertionOperator["=="]: (lambda a, b: a == b, "should be"),
137138
AssertionOperator["!="]: (lambda a, b: a != b, "should not be"),
138139
AssertionOperator["*="]: (lambda a, b: b.issubset(a), "should contain"),
@@ -145,15 +146,15 @@
145146
T = TypeVar("T")
146147

147148

148-
def apply_formatters(value: T, formatters: Optional[List[Any]]) -> Any:
149+
def apply_formatters(value: T, formatters: list[Any] | None) -> Any:
149150
if not formatters:
150151
return value
151152
for formatter in formatters:
152153
value = formatter(value)
153154
return value
154155

155156

156-
def apply_to_expected(expected: Any, formatters: Optional[List[Any]]) -> Any:
157+
def apply_to_expected(expected: Any, formatters: list[Any] | None) -> Any:
157158
if not formatters:
158159
return expected
159160
for formatter in formatters:
@@ -164,11 +165,11 @@ def apply_to_expected(expected: Any, formatters: Optional[List[Any]]) -> Any:
164165

165166
def verify_assertion(
166167
value: T,
167-
operator: Optional[AssertionOperator],
168+
operator: AssertionOperator | None,
168169
expected: Any,
169170
message: str = "",
170-
custom_message: Optional[str] = None,
171-
formatters: Optional[list] = None,
171+
custom_message: str | None = None,
172+
formatters: list | None = None,
172173
) -> Any:
173174
if operator is None and expected:
174175
raise ValueError(
@@ -193,11 +194,11 @@ def verify_assertion(
193194

194195

195196
def flag_verify_assertion(
196-
value: Union[IntFlag, Flag],
197-
operator: Optional[AssertionOperator],
197+
value: IntFlag | Flag,
198+
operator: AssertionOperator | None,
198199
expected: Any,
199200
message: str = "",
200-
custom_message: Optional[str] = None,
201+
custom_message: str | None = None,
201202
) -> Any:
202203
if not isinstance(value, Flag):
203204
raise TypeError(f"Verified value was not of type Flag. It was {type(value)}")
@@ -273,7 +274,7 @@ def raise_error(custom_message, expected, filler, message, text, value):
273274

274275
def float_str_verify_assertion(
275276
value: T,
276-
operator: Optional[AssertionOperator],
277+
operator: AssertionOperator | None,
277278
expected: Any,
278279
message="",
279280
custom_message="",
@@ -294,7 +295,7 @@ def float_str_verify_assertion(
294295

295296
def int_str_verify_assertion(
296297
value: T,
297-
operator: Optional[AssertionOperator],
298+
operator: AssertionOperator | None,
298299
expected: Any,
299300
message="",
300301
custom_message="",
@@ -315,7 +316,7 @@ def int_str_verify_assertion(
315316

316317
def bool_verify_assertion(
317318
value: T,
318-
operator: Optional[AssertionOperator],
319+
operator: AssertionOperator | None,
319320
expected: Any,
320321
message="",
321322
custom_message="",
@@ -330,7 +331,7 @@ def bool_verify_assertion(
330331
return verify_assertion(value, operator, expected_bool, message, custom_message)
331332

332333

333-
def map_list(selected: List):
334+
def map_list(selected: list):
334335
if not selected or len(selected) == 0:
335336
return None
336337
if len(selected) == 1:
@@ -339,9 +340,9 @@ def map_list(selected: List):
339340

340341

341342
def list_verify_assertion(
342-
value: List,
343-
operator: Optional[AssertionOperator],
344-
expected: List,
343+
value: list,
344+
operator: AssertionOperator | None,
345+
expected: list,
345346
message="",
346347
custom_message="",
347348
):
@@ -382,9 +383,9 @@ def list_verify_assertion(
382383

383384

384385
def dict_verify_assertion(
385-
value: Dict,
386-
operator: Optional[AssertionOperator],
387-
expected: Optional[Dict],
386+
value: dict,
387+
operator: AssertionOperator | None,
388+
expected: dict | None,
388389
message="",
389390
custom_message="",
390391
):
@@ -397,9 +398,9 @@ def dict_verify_assertion(
397398

398399

399400
def int_dict_verify_assertion(
400-
value: Dict[str, int],
401-
operator: Optional[AssertionOperator],
402-
expected: Optional[Dict[str, int]],
401+
value: dict[str, int],
402+
operator: AssertionOperator | None,
403+
expected: dict[str, int] | None,
403404
message="",
404405
custom_message="",
405406
):

assertionengine/assertion_formatter.py renamed to src/assertionengine/assertion_formatter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import re
22
from abc import ABC, abstractmethod
3-
from typing import List
43

54

65
def _strip(value: str) -> str:
@@ -37,5 +36,5 @@ def set_formatter(self, keyword, formatter): ...
3736
def normalize_keyword(self, name: str):
3837
return name.lower().replace(" ", "_")
3938

40-
def formatters_to_method(self, kw_formatter: List) -> List:
39+
def formatters_to_method(self, kw_formatter: list) -> list:
4140
return [FormatRules[formatter.lower()] for formatter in kw_formatter]

tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def lint_robot(ctx):
8989
@task(lint_robot)
9090
def lint(ctx, error=False):
9191
"""Lint Robot Framework test data and Python code."""
92-
ruff_format_command = ["ruff", "format", "assertionengine", "utest", "tasks.py"]
93-
ruff_check_command = ["ruff", "check", "assertionengine"]
92+
ruff_format_command = ["ruff", "format", "src/assertionengine", "utest", "tasks.py"]
93+
ruff_check_command = ["ruff", "check", "src/assertionengine"]
9494
if error:
9595
ruff_format_command.insert(2, "--check")
9696
else:
@@ -101,7 +101,7 @@ def lint(ctx, error=False):
101101
print(f"Run Ruff: {ruff_check_command}")
102102
ctx.run(" ".join(ruff_check_command))
103103
print("Run mypy")
104-
ctx.run("mypy --config-file ./pyproject.toml assertionengine/")
104+
ctx.run("mypy --config-file ./pyproject.toml src/assertionengine/")
105105

106106

107107
@task

0 commit comments

Comments
 (0)