Skip to content

Commit 83f90ec

Browse files
committed
fix(world_state): restructure is-not-None guard for pylint 4.0.4 type narrowing
Pylint 4.0.4 does not narrow Optional types through early-return None guards on instance attributes. Restructure the membership-test block inside an positive guard instead of using an early-exit pattern. Semantically equivalent; resolves E1135/E1133 pylint errors: - world_state.py:295: E1135 unsupported-membership-test - world_state.py:298/301: E1133 not-an-iterable Fixes #259
1 parent 89b6fbd commit 83f90ec

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

concordia/components/game_master/world_state.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,18 @@ def _normalize_location(self, location: str) -> str:
290290
if not location:
291291
return ''
292292
location = location.strip().rstrip('.')
293-
if self._valid_locations is None:
294-
return location
295-
valid_locations = self._valid_locations
296-
assert valid_locations is not None # Already checked above
297-
if location in valid_locations:
298-
return location
299-
location_lower = location.lower()
300-
for valid in valid_locations:
301-
if valid.lower() == location_lower:
302-
return valid
303-
for valid in valid_locations:
304-
if valid.lower() in location_lower:
305-
return valid
306-
return ''
293+
if self._valid_locations is not None:
294+
if location in self._valid_locations:
295+
return location
296+
location_lower = location.lower()
297+
for valid in self._valid_locations:
298+
if valid.lower() == location_lower:
299+
return valid
300+
for valid in self._valid_locations:
301+
if valid.lower() in location_lower:
302+
return valid
303+
return ''
304+
return location
307305

308306
def post_act(
309307
self,

0 commit comments

Comments
 (0)