Skip to content

Commit 19d9f49

Browse files
committed
Use ruff
1 parent c428c55 commit 19d9f49

28 files changed

+216
-105
lines changed

atest/DynamicLibrary.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from robotlibcore import DynamicCore, keyword
2-
31
import librarycomponents
2+
from robotlibcore import DynamicCore, keyword
43

54

65
class DynamicLibrary(DynamicCore):
76
"""General library documentation."""
87
class_attribute = 'not keyword'
98

10-
def __init__(self, arg=None):
9+
def __init__(self, arg=None) -> None:
1110
"""Library init doc."""
1211
components = [librarycomponents,
1312
librarycomponents.Names(),

atest/DynamicTypesAnnotationsLibrary.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from enum import Enum
22
from functools import wraps
3-
from typing import List, Union, NewType, Optional, Tuple, Dict
3+
from typing import Dict, List, NewType, Optional, Tuple, Union
44

55
from robot.api import logger
6-
76
from robotlibcore import DynamicCore, keyword
87

98
UserId = NewType('UserId', int)
@@ -28,14 +27,14 @@ def wrapper(*args, **kwargs):
2827

2928
class CustomObject:
3029

31-
def __init__(self, x, y):
30+
def __init__(self, x, y) -> None:
3231
self.x = x
3332
self.y = y
3433

3534

3635
class DynamicTypesAnnotationsLibrary(DynamicCore):
3736

38-
def __init__(self, arg: str):
37+
def __init__(self, arg: str) -> None:
3938
DynamicCore.__init__(self, [])
4039
self.instance_attribute = 'not keyword'
4140
self.arg = arg
@@ -74,7 +73,11 @@ def keyword_with_webdriver(self, arg: CustomObject):
7473
return arg
7574

7675
@keyword
77-
def keyword_default_and_annotation(self: 'DynamicTypesAnnotationsLibrary', arg1: int, arg2: Union[bool, str] = False) -> str:
76+
def keyword_default_and_annotation(
77+
self: 'DynamicTypesAnnotationsLibrary',
78+
arg1: int,
79+
arg2: Union[bool, str] = False
80+
) -> str:
7881
return '{}: {}, {}: {}'.format(arg1, type(arg1), arg2, type(arg2))
7982

8083
@keyword(types={'arg': str})
@@ -90,7 +93,10 @@ def keyword_robot_types_and_bool_hint(self, arg1, arg2: bool):
9093
return '{}: {}, {}: {}'.format(arg1, type(arg1), arg2, type(arg2))
9194

9295
@keyword
93-
def keyword_exception_annotations(self: 'DynamicTypesAnnotationsLibrary', arg: 'NotHere'):
96+
def keyword_exception_annotations(
97+
self: 'DynamicTypesAnnotationsLibrary',
98+
arg: 'NotHere' # noqa F821
99+
):
94100
return arg
95101

96102
@keyword
@@ -124,16 +130,29 @@ def keyword_mandatory_and_keyword_only_arguments(self, arg: int, *vararg, some:
124130
return f'{arg}, {vararg}, {some}'
125131

126132
@keyword
127-
def keyword_all_args(self: 'DynamicTypesAnnotationsLibrary', mandatory, positional=1, *varargs, other, value=False, **kwargs):
133+
def keyword_all_args(
134+
self: 'DynamicTypesAnnotationsLibrary',
135+
mandatory,
136+
positional=1,
137+
*varargs,
138+
other,
139+
value=False,
140+
**kwargs
141+
):
128142
return True
129143

130144
@keyword
131145
def keyword_self_and_types(self: 'DynamicTypesAnnotationsLibrary', mandatory: str, *varargs, other: bool, **kwargs):
132146
return True
133147

134148
@keyword
135-
def keyword_self_and_keyword_only_types(x: 'DynamicTypesAnnotationsLibrary', mandatory, *varargs: int, other: bool,
136-
**kwargs: int):
149+
def keyword_self_and_keyword_only_types(
150+
x: 'DynamicTypesAnnotationsLibrary', # noqa: N805
151+
mandatory,
152+
*varargs: int,
153+
other: bool,
154+
**kwargs: int
155+
):
137156
return (f'{mandatory}: {type(mandatory)}, {varargs}: {type(varargs)}, '
138157
f'{other}: {type(other)}, {kwargs}: {type(kwargs)}')
139158

atest/DynamicTypesLibrary.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sys
33

44
from robot import version as rf_version
5-
65
from robotlibcore import DynamicCore, keyword
76

87

@@ -19,7 +18,7 @@ def wrapper(*args, **kwargs):
1918

2019
class DynamicTypesLibrary(DynamicCore):
2120

22-
def __init__(self, arg=False):
21+
def __init__(self, arg=False) -> None:
2322
DynamicCore.__init__(self, [])
2423
self.instance_attribute = 'not keyword'
2524
self.arg = arg
@@ -84,4 +83,4 @@ def keyword_booleans(self, arg1=True, arg2=False):
8483

8584
@keyword
8685
def is_rf_401(self):
87-
return "4.0." in rf_version.VERSION
86+
return "4.0." in rf_version.VERSION

atest/ExtendExistingLibrary.py

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

44
class ExtendExistingLibrary(HybridLibrary):
55

6-
def __init__(self):
6+
def __init__(self) -> None:
77
HybridLibrary.__init__(self)
88
self.add_library_components([ExtendingComponent()])
99

atest/HybridLibrary.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from robotlibcore import HybridCore, keyword
2-
31
import librarycomponents
2+
from robotlibcore import HybridCore, keyword
43

54

65
class HybridLibrary(HybridCore):
76
"""General library documentation."""
87
class_attribute = 'not keyword'
98

10-
def __init__(self):
9+
def __init__(self) -> None:
1110
components = [librarycomponents,
1211
librarycomponents.Names(),
1312
librarycomponents.Arguments(),

atest/ListenerCore.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ListenerCore(DynamicCore):
55

66
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
77

8-
def __init__(self):
8+
def __init__(self) -> None:
99
self.keyword_name = None
1010
self.keyword_args = {}
1111
self.ROBOT_LISTENER_API_VERSION = 2
@@ -16,7 +16,9 @@ def __init__(self):
1616

1717
@keyword
1818
def listener_core(self, arg: str):
19-
assert arg == self.keyword_args.get("args", [None])[0], "First argument should be detected by listener, but was not."
19+
assert arg == self.keyword_args.get(
20+
"args", [None]
21+
)[0], "First argument should be detected by listener, but was not."
2022

2123
def start_keyword(self, name, args):
2224
self.keyword_name = name
@@ -25,7 +27,7 @@ def start_keyword(self, name, args):
2527

2628
class FirstComponent:
2729

28-
def __init__(self):
30+
def __init__(self) -> None:
2931
self.ROBOT_LISTENER_API_VERSION = 2
3032
self.suite_name = ''
3133

@@ -39,7 +41,7 @@ def first_component(self, arg: str):
3941

4042
class SecondComponent:
4143

42-
def __init__(self):
44+
def __init__(self) -> None:
4345
self.listener = ExternalListener()
4446

4547
@keyword
@@ -51,7 +53,7 @@ class ExternalListener:
5153

5254
ROBOT_LISTENER_API_VERSION = 3
5355

54-
def __init__(self):
56+
def __init__(self) -> None:
5557
self.test = None
5658

5759
def start_test(self, test, _):

atest/Python310Library.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from robot.api import logger
2-
32
from robotlibcore import DynamicCore, keyword
43

54

65
class Python310Library(DynamicCore):
76

8-
def __init__(self):
7+
def __init__(self) -> None:
98
DynamicCore.__init__(self, [])
109

1110
@keyword

atest/moc_library.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ def named_only_with_defaults(self, *varargs, key1, key2, key3='default1', key4=T
3939
def args_with_type_hints(self, arg1, arg2, arg3: str, arg4: None) -> bool:
4040
pass
4141

42-
def self_and_keyword_only_types(x: 'MockLibrary', mandatory, *varargs: int, other: bool, **kwargs: int):
42+
def self_and_keyword_only_types(
43+
x: 'MockLibrary', # noqa: N805
44+
mandatory,
45+
*varargs: int,
46+
other: bool,
47+
**kwargs: int
48+
):
4349
pass
4450

4551
def optional_none(self, xxx, arg1: Optional[str] = None, arg2: Optional[str] = None, arg3=False):

atest/plugin_api/MyPluginBase.py

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

66
class MyPluginBase(BaseClass):
77

8-
def __init__(self, arg):
8+
def __init__(self, arg) -> None:
99
self.arg = int(arg)
1010

1111
@keyword

atest/plugin_api/MyPluginWithPythonObjects.py

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

66
class MyPluginWithPythonObjects(BaseWithPython):
77

8-
def __init__(self, py1, py2, rf1, rf2):
8+
def __init__(self, py1, py2, rf1, rf2) -> None:
99
self.rf1 = int(rf1)
1010
self.rf2 = int(rf2)
1111
super().__init__(py1, py2)

0 commit comments

Comments
 (0)