Skip to content

Commit 01c1816

Browse files
committed
Drop RF32 support more
Fixes #85
1 parent 95d7b37 commit 01c1816

File tree

4 files changed

+4
-49
lines changed

4 files changed

+4
-49
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
matrix:
1111
python-version: [3.6, 3.9, pypy3, 3.10.0-rc.1]
12-
rf-version: [4.0.2, 4.1.1rc1]
12+
rf-version: [4.0.2, 4.1.1]
1313

1414
steps:
1515
- uses: actions/checkout@v2

src/robotlibcore.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
import os
2323
import typing
2424

25-
from robot import __version__ as robot_version
2625
from robot.utils import PY_VERSION
2726

2827

2928
from robot.api.deco import keyword # noqa F401
3029

31-
RF32 = robot_version < '4.'
32-
3330
__version__ = '3.0.1.dev1'
3431

3532

@@ -244,9 +241,6 @@ def _get_typing_hints(cls, function):
244241
# remove return and self statements
245242
if arg_with_hint not in all_args:
246243
hints.pop(arg_with_hint)
247-
if RF32:
248-
default = cls._get_defaults(arg_spec)
249-
return cls._remove_optional_none_type_hints(hints, default)
250244
return hints
251245

252246
@classmethod
@@ -260,29 +254,6 @@ def _args_as_list(cls, function, arg_spec):
260254
function_args.append(arg_spec.varkw)
261255
return function_args
262256

263-
# TODO: Remove when support RF 3.2 is dropped
264-
# Copied from: robot.running.arguments.argumentparser
265-
@classmethod
266-
def _remove_optional_none_type_hints(cls, type_hints, defaults):
267-
# If argument has None as a default, typing.get_type_hints adds
268-
# optional None to the information it returns. We don't want that.
269-
for arg, default in defaults:
270-
if default is None and arg in type_hints:
271-
type_ = type_hints[arg]
272-
if cls._is_union(type_):
273-
types = type_.__args__
274-
if len(types) == 2 and types[1] is type(None): # noqa
275-
type_hints[arg] = types[0]
276-
return type_hints
277-
278-
# TODO: Remove when support RF 3.2 is dropped
279-
# Copied from: robot.running.arguments.argumentparser
280-
@classmethod
281-
def _is_union(cls, typing_type):
282-
if PY_VERSION >= (3, 7) and hasattr(typing_type, '__origin__'):
283-
typing_type = typing_type.__origin__
284-
return isinstance(typing_type, type(typing.Union))
285-
286257
@classmethod
287258
def _get_defaults(cls, arg_spec):
288259
if not arg_spec.defaults:

utest/test_get_keyword_types.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import pytest
22
import typing
33

4-
from robotlibcore import RF32
5-
64
from typing import List, Union
75

86
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
@@ -185,13 +183,6 @@ def test_keyword_with_decorator_arguments(lib_types):
185183
assert types == {'arg1': bool, 'arg2': bool}
186184

187185

188-
@pytest.mark.skipif(RF32, reason='Only for RF4+')
189-
def test_keyword_optional_with_none_rf4(lib_types):
186+
def test_keyword_optional_with_none(lib_types):
190187
types = lib_types.get_keyword_types('keyword_optional_with_none')
191188
assert types == {'arg': typing.Union[str, type(None)]}
192-
193-
194-
@pytest.mark.skipif(not RF32, reason='Only for RF3.2+')
195-
def test_keyword_optional_with_none_rf32(lib_types):
196-
types = lib_types.get_keyword_types('keyword_optional_with_none')
197-
assert types == {'arg': str}

utest/test_keyword_builder.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
import typing
33

4-
from robotlibcore import KeywordBuilder, RF32
4+
from robotlibcore import KeywordBuilder
55
from moc_library import MockLibrary
66
from DynamicTypesAnnotationsLibrary import DynamicTypesAnnotationsLibrary
77

@@ -78,14 +78,7 @@ def test_types(lib):
7878
assert spec.argument_types == {'varargs': int, 'other': bool, 'kwargs': int}
7979

8080

81-
@pytest.mark.skipif(not RF32, reason='Only for RF3.2+')
82-
def test_optional_none_rf32(lib):
83-
spec = KeywordBuilder.build(lib.optional_none)
84-
assert spec.argument_types == {'arg1': str, 'arg2': str}
85-
86-
87-
@pytest.mark.skipif(RF32, reason='Only for RF4')
88-
def test_optional_none_rf4(lib):
81+
def test_optional_none(lib):
8982
spec = KeywordBuilder.build(lib.optional_none)
9083
assert spec.argument_types == {'arg1': typing.Union[str, None], 'arg2': typing.Union[str, None]}
9184

0 commit comments

Comments
 (0)