Skip to content

feat(commons): enable typecheck for Allure API #850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ exclude =
./tests/allure_behave/acceptance/**/test-data/**
./tests/allure_behave/acceptance/behave_support/background/background_steps.py
per-file-ignores =
./allure-python-commons/src/model2.py:A003
./allure-python-commons/src/types.py:A005
./allure-python-commons/src/allure_commons/types.py:A005
./allure-robotframework/src/listener/types.py:A005
2 changes: 1 addition & 1 deletion allure-python-commons/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[tool.poe.tasks]
linter = "flake8 --extend-ignore=A001,A002,A003 ./src"
tests = "python -m doctest ./src/*.py"
tests = "python -m doctest ./src/allure_commons/*.py"
43 changes: 23 additions & 20 deletions allure-python-commons/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
PACKAGE = "allure-python-commons"

classifiers = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Software Development :: Testing',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

install_requires = [
Expand All @@ -33,10 +33,10 @@ def main():
setup(
name=PACKAGE,
use_scm_version={"root": "..", "relative_to": __file__},
setup_requires=['setuptools_scm'],
setup_requires=["setuptools_scm"],
description=(
"Contains the API for end users as well as helper functions and "
"classes to build Allure adapters for Python test frameworks",
"classes to build Allure adapters for Python test frameworks"
),
url="https://allurereport.org/",
project_urls={
Expand All @@ -49,13 +49,16 @@ def main():
keywords="allure reporting report-engine",
long_description=get_readme("README.md"),
long_description_content_type="text/markdown",
packages=["allure_commons"],
package_dir={"allure_commons": 'src'},
packages=["allure_commons", "allure"],
package_data={
"allure": ["py.typed"],
"allure_commons": ["py.typed"],
},
package_dir={"": "src"},
install_requires=install_requires,
py_modules=['allure', 'allure_commons'],
python_requires='>=3.6'
python_requires=">=3.6"
)


if __name__ == '__main__':
if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from allure_commons._allure import label
from allure_commons._allure import severity
from allure_commons._allure import tag
from allure_commons._allure import id
from allure_commons._allure import id # noqa: A004
from allure_commons._allure import suite, parent_suite, sub_suite
from allure_commons._allure import epic, feature, story
from allure_commons._allure import link, issue, testcase
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import wraps
from typing import Any, Callable, TypeVar, overload
from typing import Any, Callable, TypeVar, Union, overload

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

@staticmethod
def parameter(name, value, excluded=None, mode: ParameterMode = None):
def parameter(name, value, excluded=None, mode: Union[ParameterMode, None] = None):
plugin_manager.hook.add_parameter(name=name, value=value, excluded=excluded, mode=mode)

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestResult(ExecutableItem):

@attrs
class TestStepResult(ExecutableItem):
id = attrib(default=None)
id = attrib(default=None) # noqa: A003


@attrs
Expand Down Expand Up @@ -82,7 +82,7 @@ class Label:

@attrs
class Link:
type = attrib(default=None)
type = attrib(default=None) # noqa: A003
url = attrib(default=None)
name = attrib(default=None)

Expand All @@ -99,7 +99,7 @@ class StatusDetails:
class Attachment:
name = attrib(default=None)
source = attrib(default=None)
type = attrib(default=None)
type = attrib(default=None) # noqa: A003


class Status:
Expand Down
Empty file.