Skip to content

Commit 93f5d8b

Browse files
committed
feat: support Python 3.0+
1 parent 172844d commit 93f5d8b

14 files changed

Lines changed: 78 additions & 112 deletions

File tree

atest/tests_types.robot

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ Keyword With Named Only Arguments
117117
Kw With Named Arguments arg=1
118118

119119
SmallLibray With New Name
120-
${data} = SmallLibrary.Other Name 123 abc
120+
${data} = SmallLibrary.Other Name 123 abc
121121
Should Be Equal ${data} 123 abc
122-
${data} = SmallLibrary.name_changed_again 1 2
122+
${data} = SmallLibrary.name_changed_again 1 2
123123
Should Be Equal As Integers ${data} 3
124124

125+
125126
*** Keywords ***
126127
Import DynamicTypesAnnotationsLibrary In Python 3.10 Only
127128
${py3} = DynamicTypesLibrary.Is Python 3 10

pyproject.toml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,39 @@
1-
[tool.black]
2-
target-version = ['py38']
3-
line-length = 120
1+
[build-system]
2+
requires = ["setuptools>=61"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "robotframework-pythonlibcore"
7+
version = "4.5.2.dev1"
8+
authors = [
9+
{name = "Tatu Aalto", email = "aalto.tatu@gmail.com"},
10+
]
11+
description = "Tools to ease creating larger test libraries for Robot Framework using Python."
12+
readme = "README.md"
13+
license = "Apache-2.0"
14+
keywords = ["robotframework", "testing", "testautomation", "library", "development"]
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Operating System :: OS Independent",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3 :: Only",
20+
"Programming Language :: Python :: Implementation :: CPython",
21+
"Programming Language :: Python :: Implementation :: PyPy",
22+
"Topic :: Software Development :: Testing",
23+
"Framework :: Robot Framework",
24+
]
25+
requires-python = ">=3.10, <4"
26+
27+
[project.urls]
28+
Homepage = "https://github.com/robotframework/PythonLibCore"
29+
30+
[tool.setuptools.packages.find]
31+
where = ["src"]
432

533
[tool.ruff]
634
line-length = 120
35+
target-version = "py310"
736
lint.fixable = ["ALL"]
8-
target-version = "py38"
937
lint.select = [
1038
"F",
1139
"E",
@@ -19,13 +47,10 @@ lint.select = [
1947
"FBT",
2048
"B",
2149
"A",
22-
"COM",
23-
"CPY",
2450
"C4",
2551
"T10",
2652
"EM",
2753
"EXE",
28-
# "FA",
2954
"ISC",
3055
"ICN",
3156
"G",
@@ -46,13 +71,8 @@ lint.select = [
4671
"RUF"
4772
]
4873

49-
[tool.ruff.lint.extend-per-file-ignores]
50-
"utest/*" = [
51-
"S",
52-
"SLF",
53-
"PLR",
54-
"B018"
55-
]
74+
[tool.ruff.lint.per-file-ignores]
75+
"utest/*" = ["S", "SLF", "B018", "PLR"]
5676

5777
[tool.ruff.lint.mccabe]
5878
max-complexity = 9

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ pytest
33
pytest-cov
44
pytest-mockito
55
robotstatuschecker
6-
black >= 25.11.0
76
ruff >= 0.15.12
8-
robotframework-tidy
7+
robotframework-robocop >= 8.0.0
98
invoke >= 3.0.3
109
twine
1110
wheel
@@ -14,3 +13,4 @@ twine
1413
wheel
1514
typing-extensions >= 4.15.0
1615
approvaltests >= 17.4.3
16+
mypy == 2.1.0

setup.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/robotlibcore/core/hybrid.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
import inspect
1717
from pathlib import Path
18-
from typing import Callable, List, Optional
18+
from typing import Callable
1919

2020
from robotlibcore.keywords import KeywordBuilder
2121
from robotlibcore.utils import _translated_keywords, _translation
2222

2323

2424
class HybridCore:
25-
def __init__(self, library_components: List, translation: Optional[Path] = None) -> None:
26-
self.keywords = {}
27-
self.keywords_spec = {}
28-
self.attributes = {}
25+
def __init__(self, library_components: list, translation: Path | None = None) -> None:
26+
self.keywords: dict = {}
27+
self.keywords_spec: dict = {}
28+
self.attributes: dict = {}
2929
translation_data = _translation(translation)
3030
translated_kw_names = _translated_keywords(translation_data)
3131
self.add_library_components(library_components, translation_data, translated_kw_names)
@@ -34,9 +34,9 @@ def __init__(self, library_components: List, translation: Optional[Path] = None)
3434

3535
def add_library_components(
3636
self,
37-
library_components: List,
38-
translation: Optional[dict] = None,
39-
translated_kw_names: Optional[list] = None,
37+
library_components: list,
38+
translation: dict | None = None,
39+
translated_kw_names: list | None = None,
4040
):
4141
translation = translation if translation else {}
4242
translated_kw_names = translated_kw_names if translated_kw_names else []
@@ -58,7 +58,7 @@ def __get_keyword_name(self, func: Callable, name: str, translation: dict, trans
5858
return name
5959
if name in translation and translation[name].get("name"):
6060
return translation[name].get("name")
61-
return func.robot_name or name
61+
return getattr(func, "robot_name", None) or name
6262

6363
def __replace_intro_doc(self, translation: dict):
6464
if "__intro__" in translation:

src/robotlibcore/keywords/builder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
from __future__ import annotations
1515

1616
import inspect
17-
from typing import Callable, Optional, get_type_hints
17+
from typing import Callable, get_type_hints
1818

1919
from .specification import KeywordSpecification
2020

2121

2222
class KeywordBuilder:
2323
@classmethod
24-
def build(cls, function, translation: Optional[dict] = None):
24+
def build(cls, function, translation: dict | None = None):
2525
translation = translation if translation else {}
2626
return KeywordSpecification(
2727
argument_specification=cls._get_arguments(function),
@@ -146,4 +146,4 @@ def _get_defaults(cls, arg_spec):
146146
if not arg_spec.defaults:
147147
return {}
148148
names = arg_spec.args[-len(arg_spec.defaults) :]
149-
return zip(names, arg_spec.defaults)
149+
return zip(names, arg_spec.defaults, strict=False)

src/robotlibcore/keywords/specification.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from __future__ import annotations
1415

1516

1617
class KeywordSpecification:

src/robotlibcore/plugin/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from __future__ import annotations
1415

1516
from .parser import PluginParser
1617

src/robotlibcore/plugin/parser.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,24 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from __future__ import annotations
1415

1516
import inspect
16-
from typing import Any, List, Optional, Union
17+
from typing import Any
1718

18-
from robot.errors import DataError
19-
from robot.utils import Importer
19+
from robot.errors import DataError # type: ignore
20+
from robot.utils import Importer # type: ignore
2021

2122
from robotlibcore.core import DynamicCore
2223
from robotlibcore.utils import Module, PluginError
2324

2425

2526
class PluginParser:
26-
def __init__(self, base_class: Optional[Any] = None, python_object=None) -> None:
27+
def __init__(self, base_class: Any | None = None, python_object=None) -> None:
2728
self._base_class = base_class
2829
self._python_object = python_object if python_object else []
2930

30-
def parse_plugins(self, plugins: Union[str, List[str]]) -> List:
31+
def parse_plugins(self, plugins: str | list[str]) -> list:
3132
imported_plugins = []
3233
importer = Importer("test library")
3334
for parsed_plugin in self._string_to_modules(plugins):
@@ -43,10 +44,10 @@ def parse_plugins(self, plugins: Union[str, List[str]]) -> List:
4344
imported_plugins.append(plugin)
4445
return imported_plugins
4546

46-
def get_plugin_keywords(self, plugins: List):
47+
def get_plugin_keywords(self, plugins: list):
4748
return DynamicCore(plugins).get_keyword_names()
4849

49-
def _string_to_modules(self, modules: Union[str, List[str]]):
50+
def _string_to_modules(self, modules: str | list[str]):
5051
parsed_modules: list = []
5152
if not modules:
5253
return parsed_modules
@@ -64,7 +65,7 @@ def _string_to_modules(self, modules: Union[str, List[str]]):
6465
parsed_modules.append(Module(module=module_name, args=args, kw_args=kw_args))
6566
return parsed_modules
6667

67-
def _modules_splitter(self, modules: Union[str, List[str]]):
68+
def _modules_splitter(self, modules: str | list[str]):
6869
if isinstance(modules, str):
6970
for module in modules.split(","):
7071
yield module

src/robotlibcore/utils/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
from __future__ import annotations
1415

1516
from dataclasses import dataclass
1617

0 commit comments

Comments
 (0)