From 3c360a3ce5f7d78b96ef8e648f25fcefd75405f6 Mon Sep 17 00:00:00 2001 From: Michael Behrisch Date: Wed, 16 Oct 2024 20:30:27 +0200 Subject: [PATCH] fixing style #22 --- tools/build_config/setup-traci.py | 4 ++-- tools/createScreenshotSequence.py | 8 ++++---- tools/generateRailSignalConstraints.py | 2 +- tools/net/abstractRail.py | 6 +++--- tools/traci/_polygon.py | 3 ++- tools/traci/_trafficlight.py | 4 ++-- tools/traci/_vehicle.py | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) mode change 100644 => 100755 tools/createScreenshotSequence.py diff --git a/tools/build_config/setup-traci.py b/tools/build_config/setup-traci.py index 500db0d7ad63..e0d74018a435 100755 --- a/tools/build_config/setup-traci.py +++ b/tools/build_config/setup-traci.py @@ -84,8 +84,8 @@ ## Contributing If you find a bug in TraCI or have a suggestion for a new feature, please report it on the SUMO issue tracker at -[https://github.com/eclipse-sumo/sumo/issues](https://github.com/eclipse-sumo/sumo/issues). If you would like to contribute -code to TraCI, please submit a pull request to the SUMO repository at +[https://github.com/eclipse-sumo/sumo/issues](https://github.com/eclipse-sumo/sumo/issues). +If you would like to contribute code to TraCI, please submit a pull request to the SUMO repository at [https://github.com/eclipse-sumo/sumo](https://github.com/eclipse-sumo/sumo). ## License diff --git a/tools/createScreenshotSequence.py b/tools/createScreenshotSequence.py old mode 100644 new mode 100755 index e2b219e0b279..caf67c861ccc --- a/tools/createScreenshotSequence.py +++ b/tools/createScreenshotSequence.py @@ -44,11 +44,11 @@ def getOptions(args=None): argParser.add_argument("--zoom", help="linear interpolation of zoom values given the key frames syntax t1:v1[;t2:v2 ...]") argParser.add_argument("--rotate", - help="linear interpolation to rotation values in degrees (around Z axis) given the key frames \ - syntax t1:v1[;t2:v2 ...]") + help="linear interpolation to rotation values in degrees (around Z axis) " + "given the key frames syntax t1:v1[;t2:v2 ...]") argParser.add_argument("--translate", - help="linear interpolation to the given view center points with the key frames syntax \ - t1:p1[;t2:p2 ...] where p1 is \"x,y\"") + help="linear interpolation to the given view center points " + "with the key frames syntax t1:p1[;t2:p2 ...] where p1 is \"x,y\"") argParser.add_argument("--include-time", dest="includeTime", category="processing", action="store_true", default=False, help="whether to include the system time at simulation begin in the file name") diff --git a/tools/generateRailSignalConstraints.py b/tools/generateRailSignalConstraints.py index 6d6fb43c38a0..293087c3395b 100755 --- a/tools/generateRailSignalConstraints.py +++ b/tools/generateRailSignalConstraints.py @@ -1843,7 +1843,7 @@ def writeConstraint(options, outf, tag, c): comment += "busStop=%s " % c.busStop commentParams.append(("busStop", c.busStop)) if c.busStop2 is not None: - if type(c.busStop2) == list: + if isinstance(c.busStop2, list): for k, v in c.busStop2: comment += "%s=%s " % (k, v) commentParams.append((k, v)) diff --git a/tools/net/abstractRail.py b/tools/net/abstractRail.py index c52c0ad7cb67..48e09bfb8ee5 100755 --- a/tools/net/abstractRail.py +++ b/tools/net/abstractRail.py @@ -210,7 +210,7 @@ def transform(coord): def getEdgeOrdering(edgeIDs, ordering, useOutgoing): result = [] for vN in ordering: - if type(vN) == sumolib.net.edge.Edge: + if isinstance(vN, sumolib.net.edge.Edge): result.append(vN.getID()) else: edges = vN.getOutgoing() if useOutgoing else vN.getIncoming() @@ -312,9 +312,9 @@ def computeTrackOrdering(options, mainLine, edges, nodeCoords, edgeShapes): def optimizeTrackOrder(options, edges, nodes, orderings, nodeCoords): constrainedEdges = set() - for nodeID, ordering in orderings: + for _, ordering in orderings: for vNode in ordering: - if type(vNode) == sumolib.net.edge.Edge: + if isinstance(vNode, sumolib.net.edge.Edge): constrainedEdges.add(vNode) # every node and every edge is assigned a single y-values diff --git a/tools/traci/_polygon.py b/tools/traci/_polygon.py index 7e53bc422d2d..421cf9233d0a 100644 --- a/tools/traci/_polygon.py +++ b/tools/traci/_polygon.py @@ -98,7 +98,8 @@ def setLineWidth(self, polygonID, lineWidth): self._setCmd(tc.VAR_WIDTH, polygonID, "d", lineWidth) def add(self, polygonID, shape, color, fill=False, polygonType="", layer=0, lineWidth=1): - """add(string, list((double, double)), (integer, integer, integer, integer), bool, string, integer, double) -> None + """add(string, list((double, double)), (integer, integer, integer, integer), + bool, string, integer, double) -> None Adds a new polygon. """ self._setCmd(tc.ADD, polygonID, "tscBipd", 6, polygonType, color, fill, layer, shape, lineWidth) diff --git a/tools/traci/_trafficlight.py b/tools/traci/_trafficlight.py index 850c13b01518..7942386586c9 100644 --- a/tools/traci/_trafficlight.py +++ b/tools/traci/_trafficlight.py @@ -367,7 +367,7 @@ def setNemaSplits(self, tlsID, splits): Time 0 must be used of the phase does not exists. Example: “11.0 34.0 15.0 20.0 11.0 34.0 15.0 20.0" (gives total cycle length of 80s) """ - if type(splits) == list: + if isinstance(splits, list): splits = ' '.join(map(str, splits)) self.setParameter(tlsID, "NEMA.splits", splits) @@ -381,7 +381,7 @@ def setNemaMaxGreens(self, tlsID, maxGreens): Time 0 must be used of the phase does not exists. Example: “11.0 34.0 15.0 20.0 11.0 34.0 15.0 20.0" """ - if type(maxGreens) == list: + if isinstance(maxGreens, list): maxGreens = ' '.join(map(str, maxGreens)) self.setParameter(tlsID, "NEMA.maxGreens", maxGreens) diff --git a/tools/traci/_vehicle.py b/tools/traci/_vehicle.py index 61c90683237a..14b202126739 100644 --- a/tools/traci/_vehicle.py +++ b/tools/traci/_vehicle.py @@ -1269,7 +1269,7 @@ def setAdaptedTraveltime(self, vehID, edgeID, time=None, begTime=None, endTime=N If begTime or endTime are not specified the value is set for the whole simulation duration. """ - if type(edgeID) != str and type(begTime) == str: + if not isinstance(edgeID, str) and isinstance(begTime, str): # legacy handling warnings.warn( "Parameter order has changed for setAdaptedTraveltime(). Attempting legacy ordering. " +