Skip to content

Commit 83d4847

Browse files
committed
debt: Drop Python 3.6 support
- Declares minimimum supported Python version as 3.7 in all packages - Removes compatibility code for Python <3.7 - Migrates to PEP563 style postponed evaluation of annotations - Applies ruff upgrade fixes for Python 3.7+ (`ruff check --target-version="py37" --select=UP --fix`) - UP008 Use `super()` instead of `super(__class__, self)` - UP015 [*] Unnecessary mode argument - UP020 [*] Use builtin `open` - UP026 [*] `mock` is deprecated, use `unittest.mock` - UP030 Use implicit references for positional format fields - UP032 [*] Use f-string instead of `format` call
1 parent 63017ae commit 83d4847

File tree

15 files changed

+46
-38
lines changed

15 files changed

+46
-38
lines changed

allure-behave/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ def main():
6161
packages=["allure_behave"],
6262
package_dir={"allure_behave": "src"},
6363
setup_requires=setup_requires,
64-
install_requires=install_requires
64+
install_requires=install_requires,
65+
python_requires=">=3.7",
6566
)
6667

6768
if __name__ == "__main__":

allure-behave/src/formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class AllureFormatter(Formatter):
1111
def __init__(self, stream_opener, config):
12-
super(AllureFormatter, self).__init__(stream_opener, config)
12+
super().__init__(stream_opener, config)
1313

1414
self.listener = AllureListener(config)
1515
self.file_logger = AllureFileLogger(self.stream_opener.name)

allure-nose2/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ def main():
5959
packages=["allure_nose2"],
6060
package_dir={"allure_nose2": "src"},
6161
setup_requires=setup_requires,
62-
install_requires=install_requires
62+
install_requires=install_requires,
63+
python_requires=">=3.7",
6364
)
6465

6566

allure-pytest-bdd/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def main():
6363
package_dir={"allure_pytest_bdd": "src"},
6464
entry_points={"pytest11": ["allure_pytest_bdd = allure_pytest_bdd.plugin"]},
6565
setup_requires=setup_requires,
66-
install_requires=install_requires
66+
install_requires=install_requires,
67+
python_requires=">=3.7",
6768
)
6869

6970

allure-pytest/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def main():
7676
package_dir={"allure_pytest": "src"},
7777
entry_points={"pytest11": ["allure_pytest = allure_pytest.plugin"]},
7878
setup_requires=setup_requires,
79-
install_requires=install_requires
79+
install_requires=install_requires,
80+
python_requires=">=3.7",
8081
)
8182

8283
if __name__ == "__main__":

allure-python-commons-test/setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ def main():
5050
long_description_content_type="text/markdown",
5151
packages=["allure_commons_test"],
5252
package_dir={"allure_commons_test": "src"},
53-
install_requires=install_requires
53+
install_requires=install_requires,
54+
python_requires=">=3.7",
5455
)
5556

5657
if __name__ == "__main__":

allure-python-commons/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main():
5656
},
5757
package_dir={"": "src"},
5858
install_requires=install_requires,
59-
python_requires=">=3.6"
59+
python_requires=">=3.7",
6060
)
6161

6262

allure-python-commons/src/allure_commons/_allure.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from __future__ import annotations
2+
13
from functools import wraps
2-
from typing import Any, Callable, TypeVar, Union, overload
4+
from typing import Any, Callable, TypeVar, overload
35

46
from allure_commons._core import plugin_manager
57
from allure_commons.types import LabelType, LinkType, ParameterMode
@@ -133,7 +135,7 @@ def link(url, link_type=LinkType.LINK, name=None):
133135
plugin_manager.hook.add_link(url=url, link_type=link_type, name=name)
134136

135137
@staticmethod
136-
def parameter(name, value, excluded=None, mode: Union[ParameterMode, None] = None):
138+
def parameter(name, value, excluded=None, mode: ParameterMode | None = None):
137139
plugin_manager.hook.add_parameter(name=name, value=value, excluded=excluded, mode=mode)
138140

139141
@staticmethod
@@ -162,7 +164,7 @@ def manual():
162164

163165

164166
@overload
165-
def step(title: str) -> "StepContext":
167+
def step(title: str) -> StepContext:
166168
...
167169

168170

allure-python-commons/src/allure_commons/logger.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import io
21
import os
32
from pathlib import Path
43
import json
@@ -22,7 +21,7 @@ def _report_item(self, item):
2221
indent = INDENT if os.environ.get("ALLURE_INDENT_OUTPUT") else None
2322
filename = item.file_pattern.format(prefix=uuid.uuid4())
2423
data = asdict(item, filter=lambda _, v: v or v is False)
25-
with io.open(self._report_dir / filename, "w", encoding="utf8") as json_file:
24+
with open(self._report_dir / filename, "w", encoding="utf8") as json_file:
2625
json.dump(data, json_file, indent=indent, ensure_ascii=False)
2726

2827
@hookimpl

allure-python-commons/src/allure_commons/utils.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
import string
3-
import sys
43
import time
54
import uuid
65
import json
@@ -41,7 +40,7 @@ def platform_label():
4140

4241

4342
def thread_tag():
44-
return "{0}-{1}".format(os.getpid(), threading.current_thread().name)
43+
return f"{os.getpid()}-{threading.current_thread().name}"
4544

4645

4746
def host_tag():
@@ -245,13 +244,7 @@ def func_parameters(func, *args, **kwargs):
245244
args_dict.pop(arg_spec.args[0], None)
246245

247246
if kwargs:
248-
if sys.version_info < (3, 7):
249-
# Sort alphabetically as old python versions does
250-
# not preserve call order for kwargs.
251-
arg_order.extend(sorted(list(kwargs.keys())))
252-
else:
253-
# Keep py3.7 behaviour to preserve kwargs order
254-
arg_order.extend(list(kwargs.keys()))
247+
arg_order.extend(list(kwargs.keys()))
255248
parameters.update(kwargs)
256249

257250
parameters.update(args_dict)
@@ -328,7 +321,7 @@ def get_testplan():
328321
file_path = os.environ.get("ALLURE_TESTPLAN_PATH")
329322

330323
if file_path and os.path.exists(file_path):
331-
with open(file_path, "r") as plan_file:
324+
with open(file_path) as plan_file:
332325
plan = json.load(plan_file)
333326
planned_tests = plan.get("tests", [])
334327

0 commit comments

Comments
 (0)