Skip to content

Commit 3ea25a2

Browse files
authored
feat(commons): enable typecheck for Allure API (#850)
1 parent 4c34305 commit 3ea25a2

17 files changed

+31
-29
lines changed

.flake8

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ exclude =
66
./tests/allure_behave/acceptance/**/test-data/**
77
./tests/allure_behave/acceptance/behave_support/background/background_steps.py
88
per-file-ignores =
9-
./allure-python-commons/src/model2.py:A003
10-
./allure-python-commons/src/types.py:A005
9+
./allure-python-commons/src/allure_commons/types.py:A005
1110
./allure-robotframework/src/listener/types.py:A005

allure-python-commons/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[tool.poe.tasks]
22
linter = "flake8 --extend-ignore=A001,A002,A003 ./src"
3-
tests = "python -m doctest ./src/*.py"
3+
tests = "python -m doctest ./src/allure_commons/*.py"

allure-python-commons/setup.py

+23-20
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
PACKAGE = "allure-python-commons"
55

66
classifiers = [
7-
'Development Status :: 5 - Production/Stable',
8-
'Intended Audience :: Developers',
9-
'License :: OSI Approved :: Apache Software License',
10-
'Topic :: Software Development :: Quality Assurance',
11-
'Topic :: Software Development :: Testing',
12-
'Programming Language :: Python :: 3',
13-
'Programming Language :: Python :: 3 :: Only',
14-
'Programming Language :: Python :: 3.8',
15-
'Programming Language :: Python :: 3.9',
16-
'Programming Language :: Python :: 3.10',
17-
'Programming Language :: Python :: 3.11',
18-
'Programming Language :: Python :: 3.12',
19-
'Programming Language :: Python :: 3.13',
7+
"Development Status :: 5 - Production/Stable",
8+
"Intended Audience :: Developers",
9+
"License :: OSI Approved :: Apache Software License",
10+
"Topic :: Software Development :: Quality Assurance",
11+
"Topic :: Software Development :: Testing",
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3 :: Only",
14+
"Programming Language :: Python :: 3.8",
15+
"Programming Language :: Python :: 3.9",
16+
"Programming Language :: Python :: 3.10",
17+
"Programming Language :: Python :: 3.11",
18+
"Programming Language :: Python :: 3.12",
19+
"Programming Language :: Python :: 3.13",
2020
]
2121

2222
install_requires = [
@@ -33,10 +33,10 @@ def main():
3333
setup(
3434
name=PACKAGE,
3535
use_scm_version={"root": "..", "relative_to": __file__},
36-
setup_requires=['setuptools_scm'],
36+
setup_requires=["setuptools_scm"],
3737
description=(
3838
"Contains the API for end users as well as helper functions and "
39-
"classes to build Allure adapters for Python test frameworks",
39+
"classes to build Allure adapters for Python test frameworks"
4040
),
4141
url="https://allurereport.org/",
4242
project_urls={
@@ -49,13 +49,16 @@ def main():
4949
keywords="allure reporting report-engine",
5050
long_description=get_readme("README.md"),
5151
long_description_content_type="text/markdown",
52-
packages=["allure_commons"],
53-
package_dir={"allure_commons": 'src'},
52+
packages=["allure_commons", "allure"],
53+
package_data={
54+
"allure": ["py.typed"],
55+
"allure_commons": ["py.typed"],
56+
},
57+
package_dir={"": "src"},
5458
install_requires=install_requires,
55-
py_modules=['allure', 'allure_commons'],
56-
python_requires='>=3.6'
59+
python_requires=">=3.6"
5760
)
5861

5962

60-
if __name__ == '__main__':
63+
if __name__ == "__main__":
6164
main()

allure-python-commons/allure.py renamed to allure-python-commons/src/allure/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from allure_commons._allure import label
44
from allure_commons._allure import severity
55
from allure_commons._allure import tag
6-
from allure_commons._allure import id
6+
from allure_commons._allure import id # noqa: A004
77
from allure_commons._allure import suite, parent_suite, sub_suite
88
from allure_commons._allure import epic, feature, story
99
from allure_commons._allure import link, issue, testcase

allure-python-commons/src/allure/py.typed

Whitespace-only changes.

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from functools import wraps
2-
from typing import Any, Callable, TypeVar, overload
2+
from typing import Any, Callable, TypeVar, Union, overload
33

44
from allure_commons._core import plugin_manager
55
from allure_commons.types import LabelType, LinkType, ParameterMode
@@ -133,7 +133,7 @@ def link(url, link_type=LinkType.LINK, name=None):
133133
plugin_manager.hook.add_link(url=url, link_type=link_type, name=name)
134134

135135
@staticmethod
136-
def parameter(name, value, excluded=None, mode: ParameterMode = None):
136+
def parameter(name, value, excluded=None, mode: Union[ParameterMode, None] = None):
137137
plugin_manager.hook.add_parameter(name=name, value=value, excluded=excluded, mode=mode)
138138

139139
@staticmethod

allure-python-commons/src/model2.py renamed to allure-python-commons/src/allure_commons/model2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class TestResult(ExecutableItem):
5353

5454
@attrs
5555
class TestStepResult(ExecutableItem):
56-
id = attrib(default=None)
56+
id = attrib(default=None) # noqa: A003
5757

5858

5959
@attrs
@@ -82,7 +82,7 @@ class Label:
8282

8383
@attrs
8484
class Link:
85-
type = attrib(default=None)
85+
type = attrib(default=None) # noqa: A003
8686
url = attrib(default=None)
8787
name = attrib(default=None)
8888

@@ -99,7 +99,7 @@ class StatusDetails:
9999
class Attachment:
100100
name = attrib(default=None)
101101
source = attrib(default=None)
102-
type = attrib(default=None)
102+
type = attrib(default=None) # noqa: A003
103103

104104

105105
class Status:

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

Whitespace-only changes.

0 commit comments

Comments
 (0)