Skip to content

Commit 7f0d05f

Browse files
[Dashing] Restore support for Python 3.5 (#324)
* Fix Python 3.5 compatibility by removing unsupported type hints. Some of the type hints introduced in Dashing are not compatible with Python 3.5. Where possible I tried to convert the hints to type comments but for the type hints within function argument lists that did not appear to be possible. This is going to make backporting future changes more challenging since we will have to: 1. Review the backported code for incompatible type hints 2. Reconcile merge conflicts caused by the removal of type hints on the Dashing development branches. * Convert list comprehension to generator (#300) Addresses flake8 C412 errors introduced by flake8-comprehension 2.2.0 * Remove type comments longer than 100 chars. It isn't clear to me from [PEP-0484] how to reconcile overlong lines with type comments. [PEP-0484]: https://www.python.org/dev/peps/pep-0484/ * Don't warn on imports used for type comments. According to [PEP-0484] types used in type comments must be imported or defined in the current module. Since flake8 is not type-comment aware (at least in Dashing PR jobs) I've noqa'd the imports. [PEP-0484]: https://www.python.org/dev/peps/pep-0484/ * Remove invalid trailing comma. * Fix a test failure due to a change in how pytest represents exceptions. This is a cherry-pick of 7b13334 from #277 to resolve a test failing on CI. Signed-off-by: Steven! Ragnarök <[email protected]>
1 parent 954c18a commit 7f0d05f

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

launch/launch/actions/execute_process.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def __init__(
197197
self.__env.append((
198198
normalize_to_list_of_substitutions(key),
199199
normalize_to_list_of_substitutions(value)))
200-
self.__additional_env: Optional[List[Tuple[List[Substitution], List[Substitution]]]] = None
200+
self.__additional_env = None
201201
if additional_env is not None:
202202
self.__additional_env = []
203203
for key, value in additional_env.items():

launch/launch/launch_description.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def process_entities(entities, *, _conditional_inclusion):
8989
for entity in entities:
9090
if isinstance(entity, DeclareLaunchArgument):
9191
# Avoid duplicate entries with the same name.
92-
if entity.name in [e.name for e in declared_launch_arguments]:
92+
if entity.name in (e.name for e in declared_launch_arguments):
9393
continue
9494
# Stuff this contextual information into the class for
9595
# potential use in command-line descriptions or errors.

launch/launch/launch_description_source.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import traceback
1818
from typing import Optional
19-
from typing import Text
19+
from typing import Text # noqa: F401
2020

2121
import launch.logging
2222

@@ -47,10 +47,10 @@ def __init__(
4747
:param location: the location from where this launch description was loaded if applicable
4848
:param method: the method by which the launch description was generated
4949
"""
50-
self.__launch_description: Optional[LaunchDescription] = launch_description
51-
self.__expanded_location: Optional[Text] = None
52-
self.__location: SomeSubstitutionsType = normalize_to_list_of_substitutions(location)
53-
self.__method: str = method
50+
self.__launch_description = launch_description # type: Optional[LaunchDescription]
51+
self.__expanded_location = None # type: Optional[Text]
52+
self.__location = normalize_to_list_of_substitutions(location)
53+
self.__method = method # type: str
5454
self.__logger = launch.logging.get_logger(__name__)
5555

5656
def try_get_launch_description_without_context(self) -> Optional[LaunchDescription]:

launch/launch/logging/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import socket
2323
import sys
2424

25-
from typing import List
25+
from typing import List # noqa: F401
2626

2727
from . import handlers
2828

@@ -387,7 +387,7 @@ def _make_unique_log_dir(*, base_path):
387387

388388
# Track all loggers to support module resets
389389
class LaunchLogger(logging.getLoggerClass()):
390-
all_loggers: List[logging.Logger] = []
390+
all_loggers = [] # type: List[logging.Logger]
391391

392392
def __new__(cls, *args, **kwargs):
393393
instance = super(LaunchLogger, cls).__new__(cls)

launch/test/launch/actions/test_include_launch_description.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_include_launch_description_launch_arguments():
110110
lc2 = LaunchContext()
111111
with pytest.raises(RuntimeError) as excinfo2:
112112
action2.visit(lc2)
113-
assert 'Included launch description missing required argument' in str(excinfo2)
113+
assert 'Included launch description missing required argument' in str(excinfo2.value)
114114

115115
# test that a declared argument that is not provided raises an error, but with other args set
116116
ld2 = LaunchDescription([DeclareLaunchArgument('foo')])
@@ -121,8 +121,8 @@ def test_include_launch_description_launch_arguments():
121121
lc2 = LaunchContext()
122122
with pytest.raises(RuntimeError) as excinfo2:
123123
action2.visit(lc2)
124-
assert 'Included launch description missing required argument' in str(excinfo2)
125-
assert 'not_foo' in str(excinfo2)
124+
assert 'Included launch description missing required argument' in str(excinfo2.value)
125+
assert 'not_foo' in str(excinfo2.value)
126126

127127
# test that a declared argument with a default value that is not provided does not raise
128128
ld2 = LaunchDescription([DeclareLaunchArgument('foo', default_value='FOO')])

launch_testing/launch_testing/io_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def waitFor(
133133
*,
134134
strict_proc_matching=True,
135135
output_filter=None,
136-
timeout=10,
136+
timeout=10
137137
):
138138
success = False
139139

0 commit comments

Comments
 (0)