Skip to content

Commit 2f7bf85

Browse files
committed
Finish first-pass replacing " -> '
1 parent baed5bf commit 2f7bf85

File tree

14 files changed

+72
-113
lines changed

14 files changed

+72
-113
lines changed

clearpath_config/common/types/discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ def is_valid(cls, mode: str) -> bool:
6161
@classmethod
6262
def assert_valid(cls, mode: str) -> None:
6363
assert cls.is_valid(mode), ('\n'.join[
64-
f'Discovery mode '{mode}' not supported.'
65-
f'Discovery mode must be one of: '{cls.ALL_SUPPORTED}''
64+
f'Discovery mode "{mode}" not supported.'
65+
f'Discovery mode must be one of: "{cls.ALL_SUPPORTED}"'
6666
])

clearpath_config/common/types/hostname.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,24 @@ def is_valid(hostname: str) -> bool:
6464
@staticmethod
6565
def assert_valid(hostname: str):
6666
assert isinstance(hostname, str), (
67-
'Hostname '%s' must be of type 'str'' % hostname
67+
'Hostname "%s" must be of type "str"' % hostname
6868
)
6969
# Min 1 ASCII Characters
7070
assert len(hostname) > 0, (
71-
'Hostname '%s' is blank.' % hostname
71+
'Hostname "%s" is blank.' % hostname
7272
)
7373
# Max 253 ASCII Characters
7474
assert len(hostname) < 254, (
75-
'Hostname '%s' exceeds 253 ASCII character limit.' % hostname
75+
'Hostname "%s" exceeds 253 ASCII character limit.' % hostname
7676
)
7777
# No Trailing Dots
7878
assert hostname[-1] != '.', (
79-
'Hostname '%s' should not end with a ('.') period.' % hostname
79+
'Hostname "%s" should not end with a "." period.' % hostname
8080
)
8181
# Only [A-Z][0-9] and '-' Allowed
8282
allowed = re.compile(r'(?!-)[A-Z\d-]{1,63}(?<!-)$', re.IGNORECASE)
8383
assert all(allowed.match(x) for x in hostname.split('.')), (
84-
'Hostname '%s' cannot contain characters other than %s.' % (
84+
'Hostname "%s" cannot contain characters other than %s.' % (
8585
hostname,
8686
'[A-Z][0-9] and hypens ('-')'
8787
)

clearpath_config/common/types/rmw_implementation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ def is_valid(cls, rmw: str) -> bool:
6161
@classmethod
6262
def assert_valid(cls, rmw: str) -> None:
6363
assert cls.is_valid(rmw), ('\n'.join[
64-
'RMW '%s' not supported.' % rmw,
65-
'RMW must be one of: '%s'' % cls.ALL_SUPPORTED
64+
'RMW "%s" not supported.' % rmw,
65+
'RMW must be one of: "%s"' % cls.ALL_SUPPORTED
6666
])

clearpath_config/common/types/username.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ def is_valid(username: str):
6565
def assert_valid(username: str):
6666
# Check Type
6767
assert isinstance(username, str), (
68-
'Username '%s' must of type 'str'' % username
68+
'Username "%s" must of type "str"' % username
6969
)
7070
# Max 255 Characters
7171
assert len(username) < 256, (
72-
'Username '%s' exceeds 255 ASCII character limit.' % username
72+
'Username "%s" exceeds 255 ASCII character limit.' % username
7373
)
7474
# Regex Convention
7575
allowed = re.compile(r'[-a-z0-9_]')
7676
assert all(allowed.match(c) for c in username), (
77-
'Username '%s' cannot contain characters other than: %s, %s, %s, %s' % (
77+
'Username "%s" cannot contain characters other than: %s, %s, %s, %s' % (
7878
username,
7979
'lowercase letters',
8080
'digits',

clearpath_config/platform/attachments/mux.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,7 @@ class AttachmentsConfigMux:
5454

5555
def __new__(cls, platform: str, attachments: dict = None) -> AttachmentsConfig:
5656
# Check Platform is Supported
57-
assert platform in cls.PLATFORM, (
58-
'Platform '%s' must be one of: '%s'' % (
59-
platform,
60-
cls.PLATFORM.keys()
61-
)
62-
)
57+
assert platform in cls.PLATFORM, f'Platform "{platform}" must be one of "{self.PLATFORM.keys()}"' # noqa:E501
6358
if not attachments:
6459
return cls.PLATFORM[platform]
6560
# Pre-Process Entries
@@ -74,8 +69,8 @@ def __new__(cls, platform: str, attachments: dict = None) -> AttachmentsConfig:
7469
@staticmethod
7570
def preprocess(platform: str, attachments: dict):
7671
for i, a in enumerate(attachments):
77-
assert 'name' in a, 'An attachment is missing 'name''
78-
assert 'type' in a, 'An attachment is missing 'type''
72+
assert 'name' in a, 'An attachment is missing "name"'
73+
assert 'type' in a, 'An attachment is missing "type"'
7974
if '.' not in a['type']:
8075
a['type'] = '%s.%s' % (platform, a['type'])
8176
attachments[i] = a

clearpath_config/sensors/sensors.py

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,7 @@ class InertialMeasurementUnit():
8080

8181
@classmethod
8282
def assert_model(cls, model: str) -> None:
83-
assert model in cls.MODEL, (
84-
'Model '%s' must be one of: '%s'' % (
85-
model,
86-
cls.MODEL.keys()
87-
)
88-
)
83+
assert model in cls.MODEL, f'Model "{model}" must be one of "{cls.MODEL.keys()}"'
8984

9085
def __new__(cls, model: str) -> BaseIMU:
9186
cls.assert_model(model)
@@ -107,12 +102,7 @@ class Camera():
107102

108103
@classmethod
109104
def assert_model(cls, model: str) -> None:
110-
assert model in cls.MODEL, (
111-
'Model '%s' must be one of: '%s'' % (
112-
model,
113-
cls.MODEL.keys()
114-
)
115-
)
105+
assert model in cls.MODEL, f'Model "{model}" must be one of "{cls.MODEL.keys()}"'
116106

117107
def __new__(cls, model: str) -> BaseCamera:
118108
cls.assert_model(model)
@@ -136,12 +126,7 @@ class GlobalPositioningSystem():
136126

137127
@classmethod
138128
def assert_model(cls, model: str) -> None:
139-
assert model in cls.MODEL, (
140-
'Model '%s' must be one of: '%s'' % (
141-
model,
142-
cls.MODEL.keys()
143-
)
144-
)
129+
assert model in cls.MODEL, f'Model "{model}" must be one of "{cls.MODEL.keys()}"'
145130

146131
def __new__(cls, model: str) -> BaseGPS:
147132
cls.assert_model(model)
@@ -159,12 +144,7 @@ class Lidar2D():
159144

160145
@classmethod
161146
def assert_model(cls, model: str) -> None:
162-
assert model in cls.MODEL, (
163-
'Model '%s' must be one of: '%s'' % (
164-
model,
165-
cls.MODEL.keys()
166-
)
167-
)
147+
assert model in cls.MODEL, f'Model "{model}" must be one of "{cls.MODEL.keys()}"'
168148

169149
def __new__(cls, model: str) -> BaseLidar2D:
170150
cls.assert_model(model)
@@ -180,12 +160,7 @@ class Lidar3D():
180160

181161
@classmethod
182162
def assert_model(cls, model: str) -> None:
183-
assert model in cls.MODEL, (
184-
'Model '%s' must be one of: '%s'' % (
185-
model,
186-
cls.MODEL.keys()
187-
)
188-
)
163+
assert model in cls.MODEL, f'Model "{model}" must be one of "{cls.MODEL.keys()}"'
189164

190165
def __new__(cls, model: str) -> BaseLidar3D:
191166
cls.assert_model(model)
@@ -209,12 +184,7 @@ class Sensor():
209184

210185
@classmethod
211186
def assert_type(cls, _type: str) -> None:
212-
assert _type in cls.TYPE, (
213-
'Sensor type '%s' must be one of: '%s'' % (
214-
_type,
215-
cls.TYPE.keys()
216-
)
217-
)
187+
assert _type in cls.TYPE, f'Sensor type "{_type}" must be one of "{cls.TYPE.keys()}"'
218188

219189
def __new__(cls, _type: str, _model: str) -> BaseSensor:
220190
cls.assert_type(_type)
@@ -319,11 +289,11 @@ def camera(self) -> OrderedListConfig:
319289
@camera.setter
320290
def camera(self, value: List[dict]) -> None:
321291
assert isinstance(value, list), (
322-
'Sensors must be list of 'dict'')
292+
'Sensors must be list of "dict"')
323293
assert all([isinstance(d, dict) for d in value]), (
324-
'Sensors must be list of 'dict'')
294+
'Sensors must be list of "dict"')
325295
assert all(['model' in d for d in value]), (
326-
'Sensor 'dict' must have 'model' key')
296+
'Sensor "dict" must have "model" key')
327297
sensor_list = []
328298
for d in value:
329299
sensor = Camera(d['model'])
@@ -342,11 +312,11 @@ def gps(self) -> OrderedListConfig:
342312
@gps.setter
343313
def gps(self, value: List[dict]) -> None:
344314
assert isinstance(value, list), (
345-
'Sensors must be list of 'dict'')
315+
'Sensors must be list of "dict"')
346316
assert all([isinstance(d, dict) for d in value]), (
347-
'Sensors must be list of 'dict'')
317+
'Sensors must be list of "dict"')
348318
assert all(['model' in d for d in value]), (
349-
'Sensor 'dict' must have 'model' key')
319+
'Sensor "dict" must have "model" key')
350320
sensor_list = []
351321
for d in value:
352322
sensor = GlobalPositioningSystem(d['model'])
@@ -365,11 +335,11 @@ def imu(self) -> OrderedListConfig:
365335
@imu.setter
366336
def imu(self, value: List[dict]) -> None:
367337
assert isinstance(value, list), (
368-
'Sensors must be list of 'dict'')
338+
'Sensors must be list of "dict"')
369339
assert all([isinstance(d, dict) for d in value]), (
370-
'Sensors must be list of 'dict'')
340+
'Sensors must be list of "dict"')
371341
assert all(['model' in d for d in value]), (
372-
'Sensor 'dict' must have 'model' key')
342+
'Sensor "dict" must have "model" key')
373343
sensor_list = []
374344
for d in value:
375345
sensor = InertialMeasurementUnit(d['model'])
@@ -388,11 +358,11 @@ def lidar2d(self) -> OrderedListConfig:
388358
@lidar2d.setter
389359
def lidar2d(self, value: List[dict]) -> None:
390360
assert isinstance(value, list), (
391-
'Sensors must be list of 'dict'')
361+
'Sensors must be list of "dict"')
392362
assert all([isinstance(d, dict) for d in value]), (
393-
'Sensors must be list of 'dict'')
363+
'Sensors must be list of "dict"')
394364
assert all(['model' in d for d in value]), (
395-
'Sensor 'dict' must have 'model' key')
365+
'Sensor "dict" must have "model" key')
396366
sensor_list = []
397367
for d in value:
398368
sensor = Lidar2D(d['model'])
@@ -411,11 +381,11 @@ def lidar3d(self) -> OrderedListConfig:
411381
@lidar3d.setter
412382
def lidar3d(self, value: List[dict]) -> None:
413383
assert isinstance(value, list), (
414-
'Sensors must be list of 'dict'')
384+
'Sensors must be list of "dict"')
415385
assert all([isinstance(d, dict) for d in value]), (
416-
'Sensors must be list of 'dict'')
386+
'Sensors must be list of "dict"')
417387
assert all(['model' in d for d in value]), (
418-
'Sensor 'dict' must have 'model' key')
388+
'Sensor "dict" must have "model" key')
419389
sensor_list = []
420390
for d in value:
421391
sensor = Lidar3D(d['model'])

clearpath_config/sensors/types/cameras.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,8 @@ class Theora(Base):
9898
}
9999

100100
def __new__(self, config: dict) -> None:
101-
assert self.TYPE in config, (
102-
'Republisher must have '%s' specified.' % self.TYPE)
103-
assert config[self.TYPE] in self.TYPES, (
104-
'Republisher '%s' must be one of: '%s'.' % (self.TYPE, [i for i in self.TYPES]))
101+
assert self.TYPE in config, f'Republisher must have "{self.TYPE}" specified'
102+
assert config[self.TYPE] in self.TYPES, f'Republisher "{self.TYPE}" must be one of "{[t for t in self.TYPES]}"' # noqa:E501
105103
return self.TYPES[config[self.TYPE]](config)
106104

107105

@@ -192,10 +190,10 @@ def set_fps(self, fps: int) -> None:
192190
@staticmethod
193191
def assert_valid_fps(fps: int) -> None:
194192
assert isinstance(fps, int), (
195-
'FPS '%s' is invalid, must be an integer.' % fps
193+
'FPS "%s" is invalid, must be an integer.' % fps
196194
)
197195
assert 0 <= fps, (
198-
'FPS '%s' must be a positive integer.' % fps
196+
'FPS "%s" must be a positive integer.' % fps
199197
)
200198

201199
@property
@@ -374,17 +372,17 @@ def clean_profile(profile: str | list) -> list:
374372
if isinstance(profile, str):
375373
profile = profile.split(',')
376374
assert len(profile) == 3, (
377-
'Profile '%s' is not three comma separated values')
375+
'Profile "%s" is not three comma separated values')
378376
try:
379377
profile = [int(entry) for entry in profile]
380378
except ValueError:
381379
raise AssertionError(
382-
'Profile '%s' cannot be cast to integer')
380+
'Profile "%s" cannot be cast to integer')
383381
else:
384382
assert len(profile) == 3, (
385-
'Profile '%s' is not three integer values')
383+
'Profile "%s" is not three integer values')
386384
assert all([isinstance(entry, int) for entry in profile]), (
387-
'Profile '%s' is not three integer values')
385+
'Profile "%s" is not three integer values')
388386
return profile
389387

390388
def assert_pixel_length(
@@ -413,7 +411,7 @@ def device_type(self) -> str:
413411
@device_type.setter
414412
def device_type(self, device_type: str) -> None:
415413
assert device_type in self.DEVICE_TYPES, (
416-
'Device type '%s' is not one of '%s'' % (
414+
'Device type "%s" is not one of "%s"' % (
417415
device_type,
418416
self.DEVICE_TYPES
419417
)
@@ -773,7 +771,7 @@ def encoding(self) -> str:
773771
@encoding.setter
774772
def encoding(self, encoding: str) -> None:
775773
assert encoding in FlirBlackfly.ENCODINGS, (
776-
'Encoding '%s' not found in support encodings: '%s'' % (
774+
'Encoding "%s" not found in support encodings: "%s"' % (
777775
encoding, FlirBlackfly.ENCODINGS
778776
)
779777
)
@@ -907,7 +905,7 @@ def device_type(self) -> str:
907905
@device_type.setter
908906
def device_type(self, device_type: str) -> None:
909907
assert device_type in self.DEVICE_TYPES, (
910-
'Device type '%s' is not one of '%s'' % (
908+
'Device type "%s" is not one of "%s"' % (
911909
device_type,
912910
self.DEVICE_TYPES
913911
)
@@ -921,7 +919,7 @@ def resolution(self) -> str:
921919
@resolution.setter
922920
def resolution(self, resolution: str) -> None:
923921
assert resolution in self.RESOLUTION_PRESETS, (
924-
'Resolution preset '%s' is not one oserial_numberf '%s'' % (
922+
'Resolution preset "%s" is not one oserial_numberf "%s"' % (
925923
resolution,
926924
self.RESOLUTION_PRESETS
927925
)

clearpath_config/sensors/types/gps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def baud(self) -> int:
293293

294294
@baud.setter
295295
def baud(self, baud: int) -> None:
296-
assert isinstance(baud, int), ('Baud must be of type 'int'.')
296+
assert isinstance(baud, int), ('Baud must be of type "int".')
297297
assert baud >= 0, ('Baud must be positive integer.')
298298
self._baud = baud
299299

@@ -374,7 +374,7 @@ def baud(self) -> int:
374374

375375
@baud.setter
376376
def baud(self, baud: int) -> None:
377-
assert isinstance(baud, int), ('Baud must be of type 'int'.')
377+
assert isinstance(baud, int), ('Baud must be of type "int".')
378378
assert baud >= 0, ('Baud must be positive integer.')
379379
self._baud = baud
380380

clearpath_config/sensors/types/lidars_3d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def device_type(self) -> str:
264264
@device_type.setter
265265
def device_type(self, device_type) -> None:
266266
assert device_type in self.DEVICE_TYPES, (
267-
'Device type '%s' is not one of '%s'' % (
267+
'Device type "%s" is not one of "%s"' % (
268268
device_type,
269269
self.DEVICE_TYPES
270270
)

clearpath_config/sensors/types/sensor.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,8 @@ def get_topic_rate(self, topic: str) -> float:
163163
return self.TOPICS.RATE[topic]
164164

165165
def set_topic(self, topic: str) -> None:
166-
assert isinstance(topic, str), (
167-
'Topic '%s' of type '%s', expected 'str'' % (topic, type(topic))
168-
)
169-
assert ' ' not in topic, (
170-
'Topic '%s' contains empty spaces.' % topic
171-
)
166+
assert isinstance(topic, str), f'Topic "{topic}" is of type "{type(topic)}", expected "str"'
167+
assert ' ' not in topic, f'Topic "{topic}" contains whitespace'
172168
self.topic = topic
173169

174170
def enable_urdf(self) -> None:
@@ -201,7 +197,7 @@ def ros_parameters_template(self) -> dict:
201197

202198
@ros_parameters_template.setter
203199
def ros_parameters_template(self, d: dict) -> None:
204-
assert isinstance(d, dict), ('Template must be of type 'dict'')
200+
assert isinstance(d, dict), ('Template must be of type "dict"')
205201
# Check that template has all properties
206202
flat = flatten_dict(d)
207203
for _, val in flat.items():

0 commit comments

Comments
 (0)