treefmt-check
checks.x86_64-linux.treefmt
· build #13
· raw
1tribuchet: building on jamie2treefmt v2.6.0ERRO formatter | ruff-check: failed to apply with options '[check --fix doc/conf.py doc/generate_command_reference.py examples/asyncio_example.py examples/coverart.py examples/errorhandling.py examples/helloworld.py examples/locking.py examples/logger.py examples/multitags.py examples/randomqueue.py examples/stats.py examples/stickers.py examples/twisted_example.py mpd/__init__.py mpd/asyncio.py mpd/base.py mpd/tests.py mpd/twisted.py]': exit status 134EXE001 Shebang is present but file is not executable5 --> doc/generate_command_reference.py:1:16 |71 | #!/usr/bin/env python8 | ^^^^^^^^^^^^^^^^^^^^^92 |103 | import os.path11 |1213BLE001 Do not catch blind exception: `Exception`14 --> examples/asyncio_example.py:15:1215 |1613 | try:1714 | await client.connect("localhost", 6600)1815 | except Exception as e:19 | ^^^^^^^^^2016 | print("Connection failed:", e)2117 | return22 |2324BLE001 Do not catch blind exception: `Exception`25 --> examples/asyncio_example.py:23:1226 |2721 | try:2822 | status = await client.status()2923 | except Exception as e:30 | ^^^^^^^^^3124 | print("Status error:", e)3225 | return33 |3435BLE001 Do not catch blind exception: `Exception`36 --> examples/asyncio_example.py:47:1237 |3845 | try:3946 | await client.addid()4047 | except Exception as e:41 | ^^^^^^^^^4248 | print("An erroneous command, as expected, raised:", e)43 |4445BLE001 Do not catch blind exception: `Exception`46 --> examples/asyncio_example.py:53:1247 |4851 | async for x in client.plchangesposid():4952 | print("Why does this work?")5053 | except Exception as e:51 | ^^^^^^^^^5254 | print("An erroneous asynchronously looped command, as expected, raised:", e)53 |5455EXE001 Shebang is present but file is not executable56 --> examples/coverart.py:1:157 |581 | #!/usr/bin/env python59 | ^^^^^^^^^^^^^^^^^^^^^602 |613 | # IMPORTS62 |6364TRY201 Use `raise` without specifying exception name65 --> examples/coverart.py:39:1566 |6737 | # mpd.base.CommandError: [50@0] {albumart} No file exists6838 | if error.errno is not FailureResponseCode.NO_EXIST:6939 | raise error70 | ^^^^^7140 |7241 | try:73 |74help: Remove exception name7576EXE001 Shebang is present but file is not executable77 --> examples/errorhandling.py:1:178 |791 | #! /usr/bin/env python80 | ^^^^^^^^^^^^^^^^^^^^^^812 | #823 | # Introduction83 |8485RUF059 Unpacked variable `errno` is never used86 --> examples/errorhandling.py:30:1387 |8828 | # Catch socket errors8929 | except OSError as err:9030 | errno, strerror = err91 | ^^^^^9231 | raise PollerError("Could not connect to '%s': %s" % (self._host, strerror))93 |94help: Prefix it with an underscore or any other dummy variable pattern9596UP031 Use format specifiers instead of percent format97 --> examples/errorhandling.py:31:3198 |9929 | except OSError as err:10030 | errno, strerror = err10131 | raise PollerError("Could not connect to '%s': %s" % (self._host, strerror))102 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^10332 |10433 | # Catch all other possible errors105 |106help: Replace with format specifiers107108UP031 Use format specifiers instead of percent format109 --> examples/errorhandling.py:38:31110 |11136 | # they are instead of ignoring them.11237 | except MPDError as e:11338 | raise PollerError("Could not connect to '%s': %s" % (self._host, e))114 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^11539 |11640 | if self._password:117 |118help: Replace with format specifiers119120UP031 Use format specifiers instead of percent format121 --> examples/errorhandling.py:49:21122 |12347 | # split into errno, offset, command and msg.12448 | raise PollerError(12549 | / "Could not connect to '%s': "12650 | | "password commmand failed: [%d] %s" % (self._host, e.errno, e.msg)127 | |_______________________________________________________^12851 | )129 |130help: Replace with format specifiers131132UP031 Use format specifiers instead of percent format133 --> examples/errorhandling.py:56:21134 |13554 | except (OSError, MPDError) as e:13655 | raise PollerError(13756 | / "Could not connect to '%s': "13857 | | "error with password command: %s" % (self._host, e)139 | |_______________________________________________________________________^14058 | )141 |142help: Replace with format specifiers143144UP031 Use format specifiers instead of percent format145 --> examples/errorhandling.py:94:35146 |14792 | # Reconnecting failed14893 | except PollerError as e:14994 | raise PollerError("Reconnecting failed: %s" % e)150 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^15195 |15296 | try:153 |154help: Replace with format specifiers155156UP031 Use format specifiers instead of percent format157 --> examples/errorhandling.py:101:35158 |159 99 | # Failed again, just give up160100 | except (OSError, MPDError) as e:161101 | raise PollerError("Couldn't retrieve current song: %s" % e)162 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^163102 |164103 | # Hurray! We got the current song without any errors!165 |166help: Replace with format specifiers167168UP031 Use format specifiers instead of percent format169 --> examples/errorhandling.py:126:15170 |171124 | # Catch fatal poller errors172125 | except PollerError as e:173126 | print("Fatal poller error: %s" % e, file=sys.stderr)174 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^175127 | sys.exit(1)176 |177help: Replace with format specifiers178179BLE001 Do not catch blind exception: `Exception`180 --> examples/errorhandling.py:130:12181 |182129 | # Catch all other non-exit errors183130 | except Exception as e:184 | ^^^^^^^^^185131 | print("Unexpected exception: %s" % e, file=sys.stderr)186132 | sys.exit(1)187 |188189UP031 Use format specifiers instead of percent format190 --> examples/errorhandling.py:131:15191 |192129 | # Catch all other non-exit errors193130 | except Exception as e:194131 | print("Unexpected exception: %s" % e, file=sys.stderr)195 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^196132 | sys.exit(1)197 |198help: Replace with format specifiers199200BLE001 Do not catch blind exception: `Exception`201 --> examples/errorhandling.py:135:12202 |203134 | # Catch the remaining exit errors204135 | except Exception:205 | ^^^^^^^^^206136 | sys.exit(0)207 |208209B025 try-except block with duplicate exception `Exception`210 --> examples/errorhandling.py:135:12211 |212134 | # Catch the remaining exit errors213135 | except Exception:214 | ^^^^^^^^^215136 | sys.exit(0)216 |217218EXE001 Shebang is present but file is not executable219 --> examples/helloworld.py:1:1220 |2211 | #!/usr/bin/python222 | ^^^^^^^^^^^^^^^^^2232 | import mpd224 |225226UP031 Use format specifiers instead of percent format227 --> examples/helloworld.py:8:11228 |229 7 | for entry in client.lsinfo("/"):230 8 | print("%s" % entry)231 | ^^^^^^^^^^^^232 9 | for key, value in client.status().items():23310 | print("%s: %s" % (key, value))234 |235help: Replace with format specifiers236237UP031 Use format specifiers instead of percent format238 --> examples/helloworld.py:10:11239 |240 8 | print("%s" % entry)241 9 | for key, value in client.status().items():24210 | print("%s: %s" % (key, value))243 | ^^^^^^^^^^^^^^^^^^^^^^^244help: Replace with format specifiers245246EXE001 Shebang is present but file is not executable247 --> examples/randomqueue.py:1:1248 |2491 | #!/usr/bin/env python250 | ^^^^^^^^^^^^^^^^^^^^^2512 |2523 | # IMPORTS253 |254255EXE001 Shebang is present but file is not executable256 --> examples/stats.py:1:1257 |2581 | #!/usr/bin/env python259 | ^^^^^^^^^^^^^^^^^^^^^2602 |2613 | # IMPORTS262 |263264EXE001 Shebang is present but file is not executable265 --> examples/stickers.py:26:1266 |26724 | # sticker.py26825 |26926 | #! /usr/bin/env python270 | ^^^^^^^^^^^^^^^^^^^^^^27127 |27228 | from optparse import OptionParser273 |274275EXE005 Shebang should be at the beginning of the file276 --> examples/stickers.py:26:1277 |27824 | # sticker.py27925 |28026 | #! /usr/bin/env python281 | ^^^^^^^^^^^^^^^^^^^^^^28227 |28328 | from optparse import OptionParser284 |285286UP031 Use format specifiers instead of percent format287 --> examples/stickers.py:74:22288 |28973 | if len(args) < 1:29074 | parser.error("no action specified, must be one of: %s" % " ".join(ACTIONS))291 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^29275 | action = args.pop(0)293 |294help: Replace with format specifiers295296UP031 Use format specifiers instead of percent format297 --> examples/stickers.py:78:22298 |29977 | if action not in ACTIONS:30078 | parser.error("action must be one of: %s" % " ".join(ACTIONS))301 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^30279 |30380 | if len(args) < 1:304 |305help: Replace with format specifiers306307UP031 Use format specifiers instead of percent format308 --> examples/stickers.py:102:13309 |310100 | except OSError as e:311101 | print(312102 | "%s: error with connection to MPD: %s" % (parser.get_prog_name(), e[1]),313 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^314103 | file=stderr,315104 | )316 |317help: Replace with format specifiers318319UP031 Use format specifiers instead of percent format320 --> examples/stickers.py:107:13321 |322105 | except MPDError as e:323106 | print(324107 | "%s: error executing action: %s" % (parser.get_prog_name(), e), file=stderr325 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^326108 | )327 |328help: Replace with format specifiers329330TRY002 Create your own exception331 --> mpd/__init__.py:37:19332 |33335 | class MPDProtocolDummy:33436 | def __init__(self) -> None:33537 | raise Exception("No twisted module found")336 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^33738 |33839 | MPDProtocol = MPDProtocolDummy # type: ignore339 |340341BLE001 Do not catch blind exception: `Exception`342 --> mpd/asyncio.py:157:16343 |344155 | async for r in self:345156 | result.append(r)346157 | except Exception as e:347 | ^^^^^^^^^348158 | self.set_exception(e)349159 | else:350 |351352C405 Unnecessary list literal (rewrite as a set literal)353 --> mpd/asyncio.py:339:38354 |355337 | # The presumably most quiet subsystem -- in this case,356338 | # idle is only used to keep the connection alive.357339 | subsystems = set(["database"])358 | ^^^^^^^^^^^^^^^^^359340 |360341 | # Careful: There can't be any await points between the361 |362help: Rewrite as a set literal363364B006 Do not use mutable data structures for argument defaults365 --> mpd/asyncio.py:472:33366 |367470 | self,368471 | lines: "asyncio.Queue[str]",369472 | delimiters: list[str] = [],370 | ^^371473 | lookup_delimiter: bool = False,372474 | ) -> AsyncIterator[dict[str, str]]:373 |374help: Replace with `None`; initialize within function375376T100 Trace found: `breakpoint` used377 --> mpd/asyncio.py:546:17378 |379544 | args[-1] = len(data)380545 | if len(data) > size:381546 | breakpoint()382 | ^^^^^^^^^^^^383547 | raise CommandListError("Binary data announced size exceeded")384548 | elif len(data) == size:385 |386387ISC004 Unparenthesized implicit string concatenation in collection388 --> mpd/asyncio.py:618:25389 |390616 | except asyncio.QueueFull as e:391617 | e.args = (392618 | / "Command queue overflowing; this indicates the"393619 | | " application sending commands in an uncontrolled"394620 | | " fashion without awaiting them, and typically"395621 | | " indicates a memory leak.",396 | |___________________________________________________^397622 | )398623 | # While we *could* indicate to the queued result that it has399 |400help: Did you forget a comma?401help: Wrap implicitly concatenated strings in parentheses402403BLE001 Do not catch blind exception: `BaseException`404 --> mpd/asyncio.py:639:24405 |406637 | try:407638 | self._write_command(result._command, result._args)408639 | except BaseException as e:409 | ^^^^^^^^^^^^^410640 | self.disconnect()411641 | result.set_exception(e)412 |413414B006 Do not use mutable data structures for argument defaults415 --> mpd/asyncio.py:650:52416 |417648 | # commands that just work differently418649 | async def idle(419650 | self, subsystems: list[str] | tuple[str] = []420 | ^^421651 | ) -> AsyncIterator[list[str] | Exception]:422652 | if self.__idle_consumers is None:423 |424help: Replace with `None`; initialize within function425426UP031 Use format specifiers instead of percent format427 --> mpd/base.py:127:17428 |429125 | if kwargs:430126 | raise AttributeError(431127 | "mpd_commands() got unexpected keyword arguments %s" % ",".join(kwargs)432 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^433128 | )434 |435help: Replace with format specifiers436437B006 Do not use mutable data structures for argument defaults438 --> mpd/base.py:213:33439 |440211 | self,441212 | lines: Iterable[str],442213 | delimiters: list[str] = [],443 | ^^444214 | lookup_delimiter: bool = False,445215 | ) -> Iterator[dict[str, str]]:446 |447help: Replace with `None`; initialize within function448449RUF059 Unpacked variable `key` is never used450 --> mpd/base.py:419:9451 |452417 | @mpd_commands("sticker get")453418 | def _parse_sticker(self, lines: list[str]) -> str:454419 | key, value = list(self._parse_raw_stickers(lines))[0]455 | ^^^456420 | return value457 |458help: Prefix it with an underscore or any other dummy variable pattern459460RUF015 Prefer `next(iter(self._parse_raw_stickers(lines)))` over single element slice461 --> mpd/base.py:419:22462 |463417 | @mpd_commands("sticker get")464418 | def _parse_sticker(self, lines: list[str]) -> str:465419 | key, value = list(self._parse_raw_stickers(lines))[0]466 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^467420 | return value468 |469help: Replace with `next(iter(self._parse_raw_stickers(lines)))`470471B006 Do not use mutable data structures for argument defaults472 --> mpd/base.py:440:59473 |474439 | def collect(475440 | cls: Any, callbacks: dict[str, tuple[Any, Any]] = {}476 | ^^477441 | ) -> dict[str, tuple[Any, Any]]:478442 | """Collect MPD command callbacks from given class.479 |480help: Replace with `None`; initialize within function481482PERF102 When using only the values of a dict use the `values()` method483 --> mpd/base.py:456:24484 |485454 | return callbacks486455 |487456 | for name, value in collect(cls).items():488 | ^^^^^^^^^^^^^^^^^^489457 | callback, from_ = value490458 | for command in callback.mpd_commands:491 |492help: Replace `.items()` with `.values()`493494RUF059 Unpacked variable `from_` is never used495 --> mpd/base.py:457:19496 |497456 | for name, value in collect(cls).items():498457 | callback, from_ = value499 | ^^^^^500458 | for command in callback.mpd_commands:501459 | cls.add_command(command, callback)502 |503help: Prefix it with an underscore or any other dummy variable pattern504505RUF012 Mutable default value for class attribute506 --> mpd/base.py:506:30507 |508504 | idletimeout = None509505 | _timeout = None510506 | _wrap_iterator_parsers = [511 | ______________________________^512507 | | MPDClientBase._parse_list,513508 | | MPDClientBase._parse_list_groups,514509 | | MPDClientBase._parse_playlist,515510 | | MPDClientBase._parse_changes,516511 | | MPDClientBase._parse_songs,517512 | | MPDClientBase._parse_mounts,518513 | | MPDClientBase._parse_neighbors,519514 | | MPDClientBase._parse_partitions,520515 | | MPDClientBase._parse_playlists,521516 | | MPDClientBase._parse_database,522517 | | MPDClientBase._parse_messages,523518 | | MPDClientBase._parse_outputs,524519 | | MPDClientBase._parse_plugins,525520 | | ]526 | |_____^527521 |528522 | def __init__(self, use_unicode: bool | None = None) -> None:529 |530help: Consider initializing in `__init__` or annotating with `typing.ClassVar`531532B006 Do not use mutable data structures for argument defaults533 --> mpd/base.py:567:62534 |535565 | raise e.with_traceback(sys.exc_info()[2])536566 |537567 | def _write_command(self, command: str, args: list[Any] = []) -> None:538 | ^^539568 | parts = [command]540569 | for arg in args:541 |542help: Replace with `None`; initialize within function543544UP031 Use format specifiers instead of percent format545 --> mpd/base.py:648:25546 |547646 | self.disconnect()548647 | raise ConnectionError(549648 | / "Connection lost while reading binary data: "550649 | | "expected %d bytes, got %d" % (chunk_size, len(value))551 | |___________________________________________________^552650 | )553 |554help: Replace with format specifiers555556UP028 Replace `yield` over `for` loop with `yield from`557 --> mpd/base.py:735:13558 |559733 | ) -> Iterator[dict[str, str]]:560734 | try:561735 | / for item in iterator:562736 | | yield item563 | |__________________________^564737 | finally:565738 | self._iterating = False566 |567help: Replace with `yield from`568569RUF059 Unpacked variable `canonname` is never used570 --> mpd/base.py:775:34571 |572773 | socket.AI_ADDRCONFIG,573774 | ):574775 | af, socktype, proto, canonname, sa = res575 | ^^^^^^^^^576776 | sock = None577777 | try:578 |579help: Prefix it with an underscore or any other dummy variable pattern580581UP031 Use format specifiers instead of percent format582 --> mpd/tests.py:1269:24583 |5841267 | next_write = self._expectations[0][0][0]5851268 | except IndexError:5861269 | self.error("Data written to mock even though none expected: %r" % data)587 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^5881270 | if next_write == data:5891271 | self._expectations[0][0].pop(0)590 |591help: Replace with format specifiers592593UP031 Use format specifiers instead of percent format594 --> mpd/tests.py:1274:24595 |5961272 | self._feed()5971273 | else:5981274 | self.error("Mock got %r, expected %r" % (data, next_write))599 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^6001275 |6011276 | def close(self) -> None:602 |603help: Replace with format specifiers604605B006 Do not use mutable data structures for argument defaults606 --> mpd/twisted.py:153:47607 |608151 | @lock609152 | def _execute(610153 | self, command: str, args: list[str] = [], parser: Callable | None = None611 | ^^612154 | ) -> defer.Deferred:613155 | # close or kill command in command list not allowed614 |615help: Replace with `None`; initialize within function616617B006 Do not use mutable data structures for argument defaults618 --> mpd/twisted.py:178:63619 |620176 | return deferred621177 |622178 | def _create_command(self, command: str, args: list[str] = []) -> bytes:623 | ^^624179 | # XXX: this function should be generalized in future. There exists625180 | # almost identical code in ``MPDClient._write_command``, with the626 |627help: Replace with `None`; initialize within function628629B006 Do not use mutable data structures for argument defaults630 --> mpd/twisted.py:195:62631 |632193 | return " ".join(parts).encode("utf-8")633194 |634195 | def _write_command(self, command: str, args: list[str] = []) -> None:635 | ^^636196 | self.sendLine(self._create_command(command, args))637 |638help: Replace with `None`; initialize within function639640Found 298 errors (242 fixed, 56 remaining).641No fixes available (33 hidden fixes can be enabled with the `--unsafe-fixes` option).642643traversed 45 files644emitted 18 files for processing645formatted 0 files (14 changed) in 208ms646Error: failed to finalise formatting: formatting failures detected