Skip to content

Commit f3048ab

Browse files
hugovkaaltat
authored andcommitted
Upgrade Python syntax with pyupgrade --py36-plus
1 parent bd21af1 commit f3048ab

File tree

8 files changed

+26
-29
lines changed

8 files changed

+26
-29
lines changed

atest/DynamicTypesAnnotationsLibrary.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def wrapper(*args, **kwargs):
2626
return actual_decorator
2727

2828

29-
class CustomObject(object):
29+
class CustomObject:
3030

3131
def __init__(self, x, y):
3232
self.x = x
@@ -75,19 +75,19 @@ def keyword_with_webdriver(self, arg: CustomObject):
7575

7676
@keyword
7777
def keyword_default_and_annotation(self: 'DynamicTypesAnnotationsLibrary', arg1: int, arg2: Union[bool, str] = False) -> str:
78-
return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2))
78+
return '{}: {}, {}: {}'.format(arg1, type(arg1), arg2, type(arg2))
7979

8080
@keyword(types={'arg': str})
8181
def keyword_robot_types_and_annotations(self: 'DynamicTypesAnnotationsLibrary', arg: int):
82-
return '%s: %s' % (arg, type(arg))
82+
return '{}: {}'.format(arg, type(arg))
8383

8484
@keyword(types=None)
8585
def keyword_robot_types_disabled_and_annotations(self, arg: int):
86-
return '%s: %s' % (arg, type(arg))
86+
return '{}: {}'.format(arg, type(arg))
8787

8888
@keyword(types={'arg1': str})
8989
def keyword_robot_types_and_bool_hint(self, arg1, arg2: bool):
90-
return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2))
90+
return '{}: {}, {}: {}'.format(arg1, type(arg1), arg2, type(arg2))
9191

9292
@keyword
9393
def keyword_exception_annotations(self: 'DynamicTypesAnnotationsLibrary', arg: 'NotHere'):

atest/DynamicTypesLibrary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def keyword_many_default_types(self, arg1=1, arg2='Foobar'):
5555

5656
@keyword
5757
def keyword_none(self, arg=None):
58-
return '%s: %s' % (arg, type(arg))
58+
return '{}: {}'.format(arg, type(arg))
5959

6060
@keyword
6161
def is_python_3(self):
@@ -74,8 +74,8 @@ def keyword_wrapped(self, number=1, arg=''):
7474

7575
@keyword
7676
def varargs_and_kwargs(self, *args, **kwargs):
77-
return '%s, %s' % (args, kwargs)
77+
return '{}, {}'.format(args, kwargs)
7878

7979
@keyword
8080
def keyword_booleans(self, arg1=True, arg2=False):
81-
return '%s: %s, %s: %s' % (arg1, type(arg1), arg2, type(arg2))
81+
return '{}: {}, {}: {}'.format(arg1, type(arg1), arg2, type(arg2))

atest/ExtendExistingLibrary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self):
88
self.add_library_components([ExtendingComponent()])
99

1010

11-
class ExtendingComponent(object):
11+
class ExtendingComponent:
1212

1313
@keyword
1414
def keyword_in_extending_library(self):

atest/librarycomponents.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
from robotlibcore import keyword
42

53

@@ -8,7 +6,7 @@ def function():
86
return 1
97

108

11-
class Names(object):
9+
class Names:
1210
attribute = 'not keyword'
1311

1412
@keyword
@@ -31,7 +29,7 @@ def dont_touch_property(self):
3129
raise RuntimeError('Should not touch property!!')
3230

3331

34-
class Arguments(object):
32+
class Arguments:
3533

3634
@keyword
3735
def mandatory(self, arg1, arg2):
@@ -61,11 +59,11 @@ def format_args(self, *args, **kwargs):
6159
def ru(item):
6260
return repr(item).lstrip('u')
6361
args = [ru(a) for a in args]
64-
kwargs = ['%s=%s' % (k, ru(kwargs[k])) for k in sorted(kwargs)]
62+
kwargs = ['{}={}'.format(k, ru(kwargs[k])) for k in sorted(kwargs)]
6563
return ', '.join(args + kwargs)
6664

6765

68-
class DocsAndTags(object):
66+
class DocsAndTags:
6967

7068
@keyword
7169
def one_line_doc(self):

atest/moc_library.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from robot.api.deco import keyword
22

33

4-
class MockLibrary(object):
4+
class MockLibrary:
55

66
def no_args(self):
77
pass

atest/run.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22

3-
from __future__ import print_function
43

54
import platform
65
from os.path import abspath, dirname, join
@@ -19,22 +18,22 @@
1918
sys.path.insert(0, join(curdir, '..', 'src'))
2019
python_version = platform.python_version()
2120
for variant in library_variants:
22-
output = join(outdir, 'lib-%s-python-%s-robot-%s.xml' % (variant, python_version, rf_version))
21+
output = join(outdir, 'lib-{}-python-{}-robot-{}.xml'.format(variant, python_version, rf_version))
2322
rc = run(tests, name=variant, variable='LIBRARY:%sLibrary' % variant,
2423
output=output, report=None, log=None, loglevel='debug')
2524
if rc > 250:
2625
sys.exit(rc)
2726
process_output(output, verbose=False)
28-
output = join(outdir, 'lib-DynamicTypesLibrary-python-%s-robot-%s.xml' % (python_version, rf_version))
27+
output = join(outdir, 'lib-DynamicTypesLibrary-python-{}-robot-{}.xml'.format(python_version, rf_version))
2928
rc = run(tests_types, name='Types', output=output, report=None, log=None, loglevel='debug')
3029
if rc > 250:
3130
sys.exit(rc)
3231
process_output(output, verbose=False)
3332
print('\nCombining results.')
3433
library_variants.append('DynamicTypesLibrary')
35-
rc = rebot(*(join(outdir, 'lib-%s-python-%s-robot-%s.xml' % (variant, python_version, rf_version)) for variant in library_variants),
36-
**dict(name='Acceptance Tests', outputdir=outdir, log='log-python-%s-robot-%s.html' % (python_version, rf_version),
37-
report='report-python-%s-robot-%s.html' % (python_version, rf_version)))
34+
rc = rebot(*(join(outdir, 'lib-{}-python-{}-robot-{}.xml'.format(variant, python_version, rf_version)) for variant in library_variants),
35+
**dict(name='Acceptance Tests', outputdir=outdir, log='log-python-{}-robot-{}.html'.format(python_version, rf_version),
36+
report='report-python-{}-robot-{}.html'.format(python_version, rf_version)))
3837
if rc == 0:
3938
print('\nAll tests passed/failed as expected.')
4039
else:

src/robotlibcore.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
__version__ = '2.2.2.dev1'
3838

3939

40-
class HybridCore(object):
40+
class HybridCore:
4141

4242
def __init__(self, library_components):
4343
self.keywords = {}
@@ -131,7 +131,7 @@ def get_keyword_source(self, keyword_name):
131131
path = self.__get_keyword_path(method)
132132
line_number = self.__get_keyword_line(method)
133133
if path and line_number:
134-
return '%s:%s' % (path, line_number)
134+
return '{}:{}'.format(path, line_number)
135135
if path:
136136
return path
137137
if line_number:
@@ -141,7 +141,7 @@ def get_keyword_source(self, keyword_name):
141141
def __get_keyword_line(self, method):
142142
try:
143143
lines, line_number = inspect.getsourcelines(method)
144-
except (OSError, IOError, TypeError):
144+
except (OSError, TypeError):
145145
return None
146146
for increment, line in enumerate(lines):
147147
if line.strip().startswith('def '):
@@ -155,7 +155,7 @@ def __get_keyword_path(self, method):
155155
return None
156156

157157

158-
class KeywordBuilder(object):
158+
class KeywordBuilder:
159159

160160
@classmethod
161161
def build(cls, function):
@@ -231,7 +231,7 @@ def _get_kw_only(cls, arg_spec):
231231
@classmethod
232232
def _format_defaults(cls, arg, value):
233233
if RF31:
234-
return '%s=%s' % (arg, value)
234+
return '{}={}'.format(arg, value)
235235
return arg, value
236236

237237
@classmethod
@@ -299,7 +299,7 @@ def _get_defaults(cls, arg_spec):
299299
return zip(names, arg_spec.defaults)
300300

301301

302-
class KeywordSpecification(object):
302+
class KeywordSpecification:
303303

304304
def __init__(self, argument_specification=None, documentation=None, argument_types=None):
305305
self.argument_specification = argument_specification

utest/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
curdir = dirname(abspath(__file__))
1111
atest_dir = join(curdir, '..', 'atest')
1212
python_version = platform.python_version()
13-
xunit_report = join(atest_dir, 'results', 'xunit-python-%s-robot%s.xml' % (python_version, rf_version))
13+
xunit_report = join(atest_dir, 'results', 'xunit-python-{}-robot{}.xml'.format(python_version, rf_version))
1414
src = join(curdir, '..', 'src')
1515
sys.path.insert(0, src)
1616
sys.path.insert(0, atest_dir)

0 commit comments

Comments
 (0)