robotframework-pythonlibcore
Advanced tools
| [tool.black] | ||
| target-version = ['py38'] | ||
| line-length = 120 | ||
| [tool.ruff] | ||
| line-length = 120 | ||
| fixable = ["ALL"] | ||
| target-version = "py38" | ||
| select = [ | ||
| "F", | ||
| "E", | ||
| "W", | ||
| "C90", | ||
| "I", | ||
| "N", | ||
| "YTT", | ||
| "S", | ||
| "BLE", | ||
| "FBT", | ||
| "B", | ||
| "A", | ||
| "COM", | ||
| "CPY", | ||
| "C4", | ||
| "T10", | ||
| "EM", | ||
| "EXE", | ||
| # "FA", | ||
| "ISC", | ||
| "ICN", | ||
| "G", | ||
| "PIE", | ||
| "PYI", | ||
| "Q", | ||
| "RSE", | ||
| "RET", | ||
| "SLF", | ||
| "SIM", | ||
| "TCH", | ||
| "INT", | ||
| "ARG", | ||
| "PTH", | ||
| "ERA", | ||
| "PL", | ||
| "PERF", | ||
| "RUF" | ||
| ] | ||
| [tool.ruff.mccabe] | ||
| max-complexity = 9 | ||
| [tool.ruff.flake8-quotes] | ||
| docstring-quotes = "double" |
+2
-2
| Metadata-Version: 2.1 | ||
| Name: robotframework-pythonlibcore | ||
| Version: 4.2.0 | ||
| Version: 4.3.0 | ||
| Summary: Tools to ease creating larger test libraries for Robot Framework using Python. | ||
@@ -24,3 +24,3 @@ Home-page: https://github.com/robotframework/PythonLibCore | ||
| Classifier: Framework :: Robot Framework | ||
| Requires-Python: >=3.7, <4 | ||
| Requires-Python: >=3.8, <4 | ||
| License-File: LICENSE.txt | ||
@@ -27,0 +27,0 @@ |
+3
-3
| #!/usr/bin/env python | ||
| import re | ||
| from os.path import abspath, join, dirname | ||
| from os.path import abspath, dirname, join | ||
| from setuptools import find_packages, setup | ||
| CURDIR = dirname(abspath(__file__)) | ||
@@ -43,3 +43,3 @@ | ||
| classifiers = CLASSIFIERS, | ||
| python_requires = '>=3.7, <4', | ||
| python_requires = '>=3.8, <4', | ||
| package_dir = {'': 'src'}, | ||
@@ -46,0 +46,0 @@ packages = find_packages('src'), |
| Metadata-Version: 2.1 | ||
| Name: robotframework-pythonlibcore | ||
| Version: 4.2.0 | ||
| Version: 4.3.0 | ||
| Summary: Tools to ease creating larger test libraries for Robot Framework using Python. | ||
@@ -24,3 +24,3 @@ Home-page: https://github.com/robotframework/PythonLibCore | ||
| Classifier: Framework :: Robot Framework | ||
| Requires-Python: >=3.7, <4 | ||
| Requires-Python: >=3.8, <4 | ||
| License-File: LICENSE.txt | ||
@@ -27,0 +27,0 @@ |
@@ -5,2 +5,3 @@ COPYRIGHT.txt | ||
| README.rst | ||
| pyproject.toml | ||
| setup.py | ||
@@ -7,0 +8,0 @@ src/robotlibcore.py |
+46
-25
@@ -26,10 +26,10 @@ # Copyright 2017- Robot Framework Foundation | ||
| from robot.api.deco import keyword # noqa F401 | ||
| from robot.api.deco import keyword # noqa: F401 | ||
| from robot.errors import DataError | ||
| from robot.utils import Importer # noqa F401 | ||
| from robot.utils import Importer | ||
| __version__ = "4.2.0" | ||
| __version__ = "4.3.0" | ||
| class PythonLibCoreException(Exception): | ||
| class PythonLibCoreException(Exception): # noqa: N818 | ||
| pass | ||
@@ -47,3 +47,3 @@ | ||
| class HybridCore: | ||
| def __init__(self, library_components): | ||
| def __init__(self, library_components: List) -> None: | ||
| self.keywords = {} | ||
@@ -56,3 +56,3 @@ self.keywords_spec = {} | ||
| def add_library_components(self, library_components): | ||
| def add_library_components(self, library_components: List): | ||
| self.keywords_spec["__init__"] = KeywordBuilder.build(self.__init__) # type: ignore | ||
@@ -90,9 +90,13 @@ for component in library_components: | ||
| if inspect.isclass(component): | ||
| msg = f"Libraries must be modules or instances, got class '{component.__name__}' instead." | ||
| raise TypeError( | ||
| "Libraries must be modules or instances, got " "class {!r} instead.".format(component.__name__) | ||
| msg, | ||
| ) | ||
| if type(component) != component.__class__: | ||
| msg = ( | ||
| "Libraries must be modules or new-style class instances, " | ||
| f"got old-style class {component.__class__.__name__} instead." | ||
| ) | ||
| raise TypeError( | ||
| "Libraries must be modules or new-style class " | ||
| "instances, got old-style class {!r} instead.".format(component.__class__.__name__) | ||
| msg, | ||
| ) | ||
@@ -111,3 +115,6 @@ return self.__get_members_from_instance(component) | ||
| return self.attributes[name] | ||
| raise AttributeError("{!r} object has no attribute {!r}".format(type(self).__name__, name)) | ||
| msg = "{!r} object has no attribute {!r}".format(type(self).__name__, name) | ||
| raise AttributeError( | ||
| msg, | ||
| ) | ||
@@ -136,3 +143,4 @@ def __dir__(self): | ||
| if not spec: | ||
| raise NoKeywordFound(f"Could not find keyword: {name}") | ||
| msg = f"Could not find keyword: {name}" | ||
| raise NoKeywordFound(msg) | ||
| return spec.argument_specification | ||
@@ -148,3 +156,4 @@ | ||
| if not spec: | ||
| raise NoKeywordFound(f"Could not find keyword: {name}") | ||
| msg = f"Could not find keyword: {name}" | ||
| raise NoKeywordFound(msg) | ||
| return spec.documentation | ||
@@ -225,2 +234,10 @@ | ||
| @classmethod | ||
| def _get_type_hint(cls, function: Callable): | ||
| try: | ||
| hints = get_type_hints(function) | ||
| except Exception: # noqa: BLE001 | ||
| hints = function.__annotations__ | ||
| return hints | ||
| @classmethod | ||
| def _get_args(cls, arg_spec: inspect.FullArgSpec, function: Callable) -> list: | ||
@@ -240,3 +257,7 @@ args = cls._drop_self_from_args(function, arg_spec) | ||
| @classmethod | ||
| def _drop_self_from_args(cls, function: Callable, arg_spec: inspect.FullArgSpec) -> list: | ||
| def _drop_self_from_args( | ||
| cls, | ||
| function: Callable, | ||
| arg_spec: inspect.FullArgSpec, | ||
| ) -> list: | ||
| return arg_spec.args[1:] if inspect.ismethod(function) else arg_spec.args | ||
@@ -278,11 +299,8 @@ | ||
| function = cls.unwrap(function) | ||
| try: | ||
| hints = get_type_hints(function) | ||
| except Exception: | ||
| hints = function.__annotations__ | ||
| hints = cls._get_type_hint(function) | ||
| arg_spec = cls._get_arg_spec(function) | ||
| all_args = cls._args_as_list(function, arg_spec) | ||
| for arg_with_hint in list(hints): | ||
| # remove return and self statements | ||
| if arg_with_hint not in all_args: | ||
| # remove self statements | ||
| if arg_with_hint not in [*all_args, "return"]: | ||
| hints.pop(arg_with_hint) | ||
@@ -310,3 +328,8 @@ return hints | ||
| class KeywordSpecification: | ||
| def __init__(self, argument_specification=None, documentation=None, argument_types=None): | ||
| def __init__( | ||
| self, | ||
| argument_specification=None, | ||
| documentation=None, | ||
| argument_types=None, | ||
| ) -> None: | ||
| self.argument_specification = argument_specification | ||
@@ -318,3 +341,3 @@ self.documentation = documentation | ||
| class PluginParser: | ||
| def __init__(self, base_class: Optional[Any] = None, python_object=None): | ||
| def __init__(self, base_class: Optional[Any] = None, python_object=None) -> None: | ||
| self._base_class = base_class | ||
@@ -347,4 +370,3 @@ self._python_object = python_object if python_object else [] | ||
| for module in self._modules_splitter(modules): | ||
| module = module.strip() | ||
| module_and_args = module.split(";") | ||
| module_and_args = module.strip().split(";") | ||
| module_name = module_and_args.pop(0) | ||
@@ -359,4 +381,3 @@ kw_args = {} | ||
| args.append(argument) | ||
| module = Module(module=module_name, args=args, kw_args=kw_args) | ||
| parsed_modules.append(module) | ||
| parsed_modules.append(Module(module=module_name, args=args, kw_args=kw_args)) | ||
| return parsed_modules | ||
@@ -363,0 +384,0 @@ |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
45294
2.22%13
8.33%364
5.81%