diff --git a/common/file_helpers.py b/common/file_helpers.py index 8a45fa313c..227d614d72 100644 --- a/common/file_helpers.py +++ b/common/file_helpers.py @@ -5,7 +5,7 @@ from atomicwrites import AtomicWriter def mkdirs_exists_ok(path): - if path.startswith('http://') or path.startswith('https://'): + if path.startswith(('http://', 'https://')): raise ValueError('URL path') try: os.makedirs(path) diff --git a/pyproject.toml b/pyproject.toml index 933af61afd..b6f45bc0fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -197,7 +197,7 @@ build-backend = "poetry.core.masonry.api" # https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml [tool.ruff] -select = ["E", "F", "W"] +select = ["E", "F", "W", "PIE"] ignore = ["W292", "E741", "E402"] line-length = 160 target-version="py311" diff --git a/scripts/code_stats.py b/scripts/code_stats.py index 6c6db4335a..25e8950ccb 100755 --- a/scripts/code_stats.py +++ b/scripts/code_stats.py @@ -40,7 +40,7 @@ for f in sorted(pyf): print("%5d %s %s" % (lns, f, xbit)) if 'test' in f: testlns += lns - elif f.startswith('tools/') or f.startswith('scripts/') or f.startswith('selfdrive/debug'): + elif f.startswith(('tools/', 'scripts/', 'selfdrive/debug')): scriptlns += lns elif f.startswith('selfdrive/car'): carlns += lns diff --git a/selfdrive/locationd/laikad.py b/selfdrive/locationd/laikad.py index cbc1822e50..e4a408d130 100755 --- a/selfdrive/locationd/laikad.py +++ b/selfdrive/locationd/laikad.py @@ -137,8 +137,8 @@ class Laikad: #TODO this only saves currently valid ephems, when we download future ephems we should save them too valid_navs = [e for e in nav_list if e.valid(self.last_report_time)] if len(valid_navs) > 0: - ephem_cache = ephemeris_structs.EphemerisCache(**{'glonassEphemerides': [e.data for e in valid_navs if e.prn[0]=='R'], - 'gpsEphemerides': [e.data for e in valid_navs if e.prn[0]=='G']}) + ephem_cache = ephemeris_structs.EphemerisCache(glonassEphemerides=[e.data for e in valid_navs if e.prn[0]=='R'], + gpsEphemerides=[e.data for e in valid_navs if e.prn[0]=='G']) put_nonblocking(EPHEMERIS_CACHE, ephem_cache.to_bytes()) cloudlog.debug("Cache saved") self.last_cached_t = self.last_report_time diff --git a/system/version.py b/system/version.py index 55f80afa35..c9ab443694 100644 --- a/system/version.py +++ b/system/version.py @@ -90,7 +90,7 @@ def is_comma_remote() -> bool: if origin is None: return False - return origin.startswith('git@github.com:commaai') or origin.startswith('https://github.com/commaai') + return origin.startswith(('git@github.com:commaai', 'https://github.com/commaai')) @cache diff --git a/tools/lib/filereader.py b/tools/lib/filereader.py index 215f7b2185..718b853b1a 100644 --- a/tools/lib/filereader.py +++ b/tools/lib/filereader.py @@ -6,6 +6,6 @@ DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/") def FileReader(fn, debug=False): if fn.startswith("cd:/"): fn = fn.replace("cd:/", DATA_ENDPOINT) - if fn.startswith("http://") or fn.startswith("https://"): + if fn.startswith(("http://", "https://")): return URLFile(fn, debug=debug) return open(fn, "rb")