nixbot

builds

failed treefmt-check checks.x86_64-linux.treefmt · build #15 · 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 name75 |7638 | if error.errno is not FailureResponseCode.NO_EXIST:77 - raise error7839 + raise7940 |80 |81note: This is an unsafe fix and may change runtime behavior8283EXE001 Shebang is present but file is not executable84 --> examples/errorhandling.py:1:185 |861 | #! /usr/bin/env python87 | ^^^^^^^^^^^^^^^^^^^^^^882 | #893 | # Introduction90 |9192RUF059 Unpacked variable `errno` is never used93 --> examples/errorhandling.py:30:1394 |9528 | # Catch socket errors9629 | except OSError as err:9730 | errno, strerror = err98 | ^^^^^9931 | raise PollerError("Could not connect to '%s': %s" % (self._host, strerror))100 |101help: Prefix it with an underscore or any other dummy variable pattern102 |10329 | except OSError as err:104 - errno, strerror = err10530 + _errno, strerror = err10631 | raise PollerError("Could not connect to '%s': %s" % (self._host, strerror))107 |108note: This is an unsafe fix and may change runtime behavior109110UP031 Use format specifiers instead of percent format111 --> examples/errorhandling.py:31:31112 |11329 | except OSError as err:11430 | errno, strerror = err11531 | raise PollerError("Could not connect to '%s': %s" % (self._host, strerror))116 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^11732 |11833 | # Catch all other possible errors119 |120help: Replace with format specifiers121 |12230 | errno, strerror = err123 - raise PollerError("Could not connect to '%s': %s" % (self._host, strerror))12431 + raise PollerError("Could not connect to '{}': {}".format(self._host, strerror))12532 |126 |127note: This is an unsafe fix and may change runtime behavior128129UP031 Use format specifiers instead of percent format130 --> examples/errorhandling.py:38:31131 |13236 | # they are instead of ignoring them.13337 | except MPDError as e:13438 | raise PollerError("Could not connect to '%s': %s" % (self._host, e))135 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^13639 |13740 | if self._password:138 |139help: Replace with format specifiers140 |14137 | except MPDError as e:142 - raise PollerError("Could not connect to '%s': %s" % (self._host, e))14338 + raise PollerError("Could not connect to '{}': {}".format(self._host, e))14439 |145 |146note: This is an unsafe fix and may change runtime behavior147148UP031 Use format specifiers instead of percent format149 --> examples/errorhandling.py:49:21150 |15147 | # split into errno, offset, command and msg.15248 | raise PollerError(15349 | / "Could not connect to '%s': "15450 | | "password commmand failed: [%d] %s" % (self._host, e.errno, e.msg)155 | |_______________________________________________________^15651 | )157 |158help: Replace with format specifiers159160UP031 Use format specifiers instead of percent format161 --> examples/errorhandling.py:56:21162 |16354 | except (OSError, MPDError) as e:16455 | raise PollerError(16556 | / "Could not connect to '%s': "16657 | | "error with password command: %s" % (self._host, e)167 | |_______________________________________________________________________^16858 | )169 |170help: Replace with format specifiers171 |17255 | raise PollerError(173 - "Could not connect to '%s': "174 - "error with password command: %s" % (self._host, e)17556 + "Could not connect to '{}': "17657 + "error with password command: {}".format(self._host, e)17758 | )178 |179note: This is an unsafe fix and may change runtime behavior180181UP031 Use format specifiers instead of percent format182 --> examples/errorhandling.py:94:35183 |18492 | # Reconnecting failed18593 | except PollerError as e:18694 | raise PollerError("Reconnecting failed: %s" % e)187 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^18895 |18996 | try:190 |191help: Replace with format specifiers192 |19393 | except PollerError as e:194 - raise PollerError("Reconnecting failed: %s" % e)19594 + raise PollerError("Reconnecting failed: {}".format(e))19695 |197 |198note: This is an unsafe fix and may change runtime behavior199200UP031 Use format specifiers instead of percent format201 --> examples/errorhandling.py:101:35202 |203 99 | # Failed again, just give up204100 | except (OSError, MPDError) as e:205101 | raise PollerError("Couldn't retrieve current song: %s" % e)206 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^207102 |208103 | # Hurray! We got the current song without any errors!209 |210help: Replace with format specifiers211 |212100 | except (OSError, MPDError) as e:213 - raise PollerError("Couldn't retrieve current song: %s" % e)214101 + raise PollerError("Couldn't retrieve current song: {}".format(e))215102 |216 |217note: This is an unsafe fix and may change runtime behavior218219UP031 Use format specifiers instead of percent format220 --> examples/errorhandling.py:126:15221 |222124 | # Catch fatal poller errors223125 | except PollerError as e:224126 | print("Fatal poller error: %s" % e, file=sys.stderr)225 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^226127 | sys.exit(1)227 |228help: Replace with format specifiers229 |230125 | except PollerError as e:231 - print("Fatal poller error: %s" % e, file=sys.stderr)232126 + print("Fatal poller error: {}".format(e), file=sys.stderr)233127 | sys.exit(1)234 |235note: This is an unsafe fix and may change runtime behavior236237BLE001 Do not catch blind exception: `Exception`238 --> examples/errorhandling.py:130:12239 |240129 | # Catch all other non-exit errors241130 | except Exception as e:242 | ^^^^^^^^^243131 | print("Unexpected exception: %s" % e, file=sys.stderr)244132 | sys.exit(1)245 |246247UP031 Use format specifiers instead of percent format248 --> examples/errorhandling.py:131:15249 |250129 | # Catch all other non-exit errors251130 | except Exception as e:252131 | print("Unexpected exception: %s" % e, file=sys.stderr)253 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^254132 | sys.exit(1)255 |256help: Replace with format specifiers257 |258130 | except Exception as e:259 - print("Unexpected exception: %s" % e, file=sys.stderr)260131 + print("Unexpected exception: {}".format(e), file=sys.stderr)261132 | sys.exit(1)262 |263note: This is an unsafe fix and may change runtime behavior264265BLE001 Do not catch blind exception: `Exception`266 --> examples/errorhandling.py:135:12267 |268134 | # Catch the remaining exit errors269135 | except Exception:270 | ^^^^^^^^^271136 | sys.exit(0)272 |273274B025 try-except block with duplicate exception `Exception`275 --> examples/errorhandling.py:135:12276 |277134 | # Catch the remaining exit errors278135 | except Exception:279 | ^^^^^^^^^280136 | sys.exit(0)281 |282283EXE001 Shebang is present but file is not executable284 --> examples/helloworld.py:1:1285 |2861 | #!/usr/bin/python287 | ^^^^^^^^^^^^^^^^^2882 | import mpd289 |290291UP031 Use format specifiers instead of percent format292 --> examples/helloworld.py:8:11293 |294 7 | for entry in client.lsinfo("/"):295 8 | print("%s" % entry)296 | ^^^^^^^^^^^^297 9 | for key, value in client.status().items():29810 | print("%s: %s" % (key, value))299 |300help: Replace with format specifiers301 |3027 | for entry in client.lsinfo("/"):303 - print("%s" % entry)3048 + print("{}".format(entry))3059 | for key, value in client.status().items():306 |307note: This is an unsafe fix and may change runtime behavior308309UP031 Use format specifiers instead of percent format310 --> examples/helloworld.py:10:11311 |312 8 | print("%s" % entry)313 9 | for key, value in client.status().items():31410 | print("%s: %s" % (key, value))315 | ^^^^^^^^^^^^^^^^^^^^^^^316help: Replace with format specifiers317 |3189 | for key, value in client.status().items():319 - print("%s: %s" % (key, value))32010 + print("{}: {}".format(key, value))321 |322note: This is an unsafe fix and may change runtime behavior323324EXE001 Shebang is present but file is not executable325 --> examples/randomqueue.py:1:1326 |3271 | #!/usr/bin/env python328 | ^^^^^^^^^^^^^^^^^^^^^3292 |3303 | # IMPORTS331 |332333EXE001 Shebang is present but file is not executable334 --> examples/stats.py:1:1335 |3361 | #!/usr/bin/env python337 | ^^^^^^^^^^^^^^^^^^^^^3382 |3393 | # IMPORTS340 |341342EXE001 Shebang is present but file is not executable343 --> examples/stickers.py:26:1344 |34524 | # sticker.py34625 |34726 | #! /usr/bin/env python348 | ^^^^^^^^^^^^^^^^^^^^^^34927 |35028 | from optparse import OptionParser351 |352353EXE005 Shebang should be at the beginning of the file354 --> examples/stickers.py:26:1355 |35624 | # sticker.py35725 |35826 | #! /usr/bin/env python359 | ^^^^^^^^^^^^^^^^^^^^^^36027 |36128 | from optparse import OptionParser362 |363364UP031 Use format specifiers instead of percent format365 --> examples/stickers.py:74:22366 |36773 | if len(args) < 1:36874 | parser.error("no action specified, must be one of: %s" % " ".join(ACTIONS))369 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^37075 | action = args.pop(0)371 |372help: Replace with format specifiers373 |37473 | if len(args) < 1:375 - parser.error("no action specified, must be one of: %s" % " ".join(ACTIONS))37674 + parser.error("no action specified, must be one of: {}".format(" ".join(ACTIONS)))37775 | action = args.pop(0)378 |379note: This is an unsafe fix and may change runtime behavior380381UP031 Use format specifiers instead of percent format382 --> examples/stickers.py:78:22383 |38477 | if action not in ACTIONS:38578 | parser.error("action must be one of: %s" % " ".join(ACTIONS))386 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^38779 |38880 | if len(args) < 1:389 |390help: Replace with format specifiers391 |39277 | if action not in ACTIONS:393 - parser.error("action must be one of: %s" % " ".join(ACTIONS))39478 + parser.error("action must be one of: {}".format(" ".join(ACTIONS)))39579 |396 |397note: This is an unsafe fix and may change runtime behavior398399UP031 Use format specifiers instead of percent format400 --> examples/stickers.py:102:13401 |402100 | except OSError as e:403101 | print(404102 | "%s: error with connection to MPD: %s" % (parser.get_prog_name(), e[1]),405 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^406103 | file=stderr,407104 | )408 |409help: Replace with format specifiers410 |411101 | print(412 - "%s: error with connection to MPD: %s" % (parser.get_prog_name(), e[1]),413102 + "{}: error with connection to MPD: {}".format(parser.get_prog_name(), e[1]),414103 | file=stderr,415 |416note: This is an unsafe fix and may change runtime behavior417418UP031 Use format specifiers instead of percent format419 --> examples/stickers.py:107:13420 |421105 | except MPDError as e:422106 | print(423107 | "%s: error executing action: %s" % (parser.get_prog_name(), e), file=stderr424 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^425108 | )426 |427help: Replace with format specifiers428 |429106 | print(430 - "%s: error executing action: %s" % (parser.get_prog_name(), e), file=stderr431107 + "{}: error executing action: {}".format(parser.get_prog_name(), e), file=stderr432108 | )433 |434note: This is an unsafe fix and may change runtime behavior435436TRY002 Create your own exception437 --> mpd/__init__.py:37:19438 |43935 | class MPDProtocolDummy:44036 | def __init__(self) -> None:44137 | raise Exception("No twisted module found")442 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^44338 |44439 | MPDProtocol = MPDProtocolDummy # type: ignore445 |446447BLE001 Do not catch blind exception: `Exception`448 --> mpd/asyncio.py:157:16449 |450155 | async for r in self:451156 | result.append(r)452157 | except Exception as e:453 | ^^^^^^^^^454158 | self.set_exception(e)455159 | else:456 |457458C405 Unnecessary list literal (rewrite as a set literal)459 --> mpd/asyncio.py:339:38460 |461337 | # The presumably most quiet subsystem -- in this case,462338 | # idle is only used to keep the connection alive.463339 | subsystems = set(["database"])464 | ^^^^^^^^^^^^^^^^^465340 |466341 | # Careful: There can't be any await points between the467 |468help: Rewrite as a set literal469 |470338 | # idle is only used to keep the connection alive.471 - subsystems = set(["database"])472339 + subsystems = {"database"}473340 |474 |475note: This is an unsafe fix and may change runtime behavior476477B006 Do not use mutable data structures for argument defaults478 --> mpd/asyncio.py:472:33479 |480470 | self,481471 | lines: "asyncio.Queue[str]",482472 | delimiters: list[str] = [],483 | ^^484473 | lookup_delimiter: bool = False,485474 | ) -> AsyncIterator[dict[str, str]]:486 |487help: Replace with `None`; initialize within function488 |489471 | lines: "asyncio.Queue[str]",490 - delimiters: list[str] = [],491472 + delimiters: list[str] = None,492473 | lookup_delimiter: bool = False,493474 | ) -> AsyncIterator[dict[str, str]]:494475 + if delimiters is None:495476 + delimiters = []496477 | obj: dict[str, Any] = {}497 |498note: This is an unsafe fix and may change runtime behavior499500T100 Trace found: `breakpoint` used501 --> mpd/asyncio.py:546:17502 |503544 | args[-1] = len(data)504545 | if len(data) > size:505546 | breakpoint()506 | ^^^^^^^^^^^^507547 | raise CommandListError("Binary data announced size exceeded")508548 | elif len(data) == size:509 |510511ISC004 Unparenthesized implicit string concatenation in collection512 --> mpd/asyncio.py:618:25513 |514616 | except asyncio.QueueFull as e:515617 | e.args = (516618 | / "Command queue overflowing; this indicates the"517619 | | " application sending commands in an uncontrolled"518620 | | " fashion without awaiting them, and typically"519621 | | " indicates a memory leak.",520 | |___________________________________________________^521622 | )522623 | # While we *could* indicate to the queued result that it has523 |524help: Did you forget a comma?525help: Wrap implicitly concatenated strings in parentheses526 |527617 | e.args = (528 - "Command queue overflowing; this indicates the"529618 + ("Command queue overflowing; this indicates the"530619 | " application sending commands in an uncontrolled"531620 | " fashion without awaiting them, and typically"532 - " indicates a memory leak.",533621 + " indicates a memory leak."),534622 | )535 |536note: This is an unsafe fix and may change runtime behavior537538BLE001 Do not catch blind exception: `BaseException`539 --> mpd/asyncio.py:639:24540 |541637 | try:542638 | self._write_command(result._command, result._args)543639 | except BaseException as e:544 | ^^^^^^^^^^^^^545640 | self.disconnect()546641 | result.set_exception(e)547 |548549B006 Do not use mutable data structures for argument defaults550 --> mpd/asyncio.py:650:52551 |552648 | # commands that just work differently553649 | async def idle(554650 | self, subsystems: list[str] | tuple[str] = []555 | ^^556651 | ) -> AsyncIterator[list[str] | Exception]:557652 | if self.__idle_consumers is None:558 |559help: Replace with `None`; initialize within function560 |561649 | async def idle(562 - self, subsystems: list[str] | tuple[str] = []563650 + self, subsystems: list[str] | tuple[str] = None564651 | ) -> AsyncIterator[list[str] | Exception]:565652 + if subsystems is None:566653 + subsystems = []567654 | if self.__idle_consumers is None:568 |569note: This is an unsafe fix and may change runtime behavior570571UP031 Use format specifiers instead of percent format572 --> mpd/base.py:127:17573 |574125 | if kwargs:575126 | raise AttributeError(576127 | "mpd_commands() got unexpected keyword arguments %s" % ",".join(kwargs)577 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^578128 | )579 |580help: Replace with format specifiers581 |582126 | raise AttributeError(583 - "mpd_commands() got unexpected keyword arguments %s" % ",".join(kwargs)584127 + "mpd_commands() got unexpected keyword arguments {}".format(",".join(kwargs))585128 | )586 |587note: This is an unsafe fix and may change runtime behavior588589B006 Do not use mutable data structures for argument defaults590 --> mpd/base.py:213:33591 |592211 | self,593212 | lines: Iterable[str],594213 | delimiters: list[str] = [],595 | ^^596214 | lookup_delimiter: bool = False,597215 | ) -> Iterator[dict[str, str]]:598 |599help: Replace with `None`; initialize within function600 |601212 | lines: Iterable[str],602 - delimiters: list[str] = [],603213 + delimiters: list[str] = None,604214 | lookup_delimiter: bool = False,605215 | ) -> Iterator[dict[str, str]]:606216 + if delimiters is None:607217 + delimiters = []608218 | obj: dict[str, Any] = {}609 |610note: This is an unsafe fix and may change runtime behavior611612RUF059 Unpacked variable `key` is never used613 --> mpd/base.py:419:9614 |615417 | @mpd_commands("sticker get")616418 | def _parse_sticker(self, lines: list[str]) -> str:617419 | key, value = list(self._parse_raw_stickers(lines))[0]618 | ^^^619420 | return value620 |621help: Prefix it with an underscore or any other dummy variable pattern622 |623418 | def _parse_sticker(self, lines: list[str]) -> str:624 - key, value = list(self._parse_raw_stickers(lines))[0]625419 + _key, value = list(self._parse_raw_stickers(lines))[0]626420 | return value627 |628note: This is an unsafe fix and may change runtime behavior629630RUF015 Prefer `next(iter(self._parse_raw_stickers(lines)))` over single element slice631 --> mpd/base.py:419:22632 |633417 | @mpd_commands("sticker get")634418 | def _parse_sticker(self, lines: list[str]) -> str:635419 | key, value = list(self._parse_raw_stickers(lines))[0]636 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^637420 | return value638 |639help: Replace with `next(iter(self._parse_raw_stickers(lines)))`640 |641418 | def _parse_sticker(self, lines: list[str]) -> str:642 - key, value = list(self._parse_raw_stickers(lines))[0]643419 + key, value = next(iter(self._parse_raw_stickers(lines)))644420 | return value645 |646note: This is an unsafe fix and may change runtime behavior647648B006 Do not use mutable data structures for argument defaults649 --> mpd/base.py:440:59650 |651439 | def collect(652440 | cls: Any, callbacks: dict[str, tuple[Any, Any]] = {}653 | ^^654441 | ) -> dict[str, tuple[Any, Any]]:655442 | """Collect MPD command callbacks from given class.656 |657help: Replace with `None`; initialize within function658 |659439 | def collect(660 - cls: Any, callbacks: dict[str, tuple[Any, Any]] = {}661440 + cls: Any, callbacks: dict[str, tuple[Any, Any]] = None662441 | ) -> dict[str, tuple[Any, Any]]:663--------------------------------------------------------------------------------664448 | """665449 + if callbacks is None:666450 + callbacks = {}667451 | for name, ob in cls.__dict__.items():668 |669note: This is an unsafe fix and may change runtime behavior670671PERF102 When using only the values of a dict use the `values()` method672 --> mpd/base.py:456:24673 |674454 | return callbacks675455 |676456 | for name, value in collect(cls).items():677 | ^^^^^^^^^^^^^^^^^^678457 | callback, from_ = value679458 | for command in callback.mpd_commands:680 |681help: Replace `.items()` with `.values()`682 |683455 |684 - for name, value in collect(cls).items():685456 + for value in collect(cls).values():686457 | callback, from_ = value687 |688note: This is an unsafe fix and may change runtime behavior689690RUF059 Unpacked variable `from_` is never used691 --> mpd/base.py:457:19692 |693456 | for name, value in collect(cls).items():694457 | callback, from_ = value695 | ^^^^^696458 | for command in callback.mpd_commands:697459 | cls.add_command(command, callback)698 |699help: Prefix it with an underscore or any other dummy variable pattern700701RUF012 Mutable default value for class attribute702 --> mpd/base.py:506:30703 |704504 | idletimeout = None705505 | _timeout = None706506 | _wrap_iterator_parsers = [707 | ______________________________^708507 | | MPDClientBase._parse_list,709508 | | MPDClientBase._parse_list_groups,710509 | | MPDClientBase._parse_playlist,711510 | | MPDClientBase._parse_changes,712511 | | MPDClientBase._parse_songs,713512 | | MPDClientBase._parse_mounts,714513 | | MPDClientBase._parse_neighbors,715514 | | MPDClientBase._parse_partitions,716515 | | MPDClientBase._parse_playlists,717516 | | MPDClientBase._parse_database,718517 | | MPDClientBase._parse_messages,719518 | | MPDClientBase._parse_outputs,720519 | | MPDClientBase._parse_plugins,721520 | | ]722 | |_____^723521 |724522 | def __init__(self, use_unicode: bool | None = None) -> None:725 |726help: Consider initializing in `__init__` or annotating with `typing.ClassVar`727728B006 Do not use mutable data structures for argument defaults729 --> mpd/base.py:567:62730 |731565 | raise e.with_traceback(sys.exc_info()[2])732566 |733567 | def _write_command(self, command: str, args: list[Any] = []) -> None:734 | ^^735568 | parts = [command]736569 | for arg in args:737 |738help: Replace with `None`; initialize within function739 |740566 |741 - def _write_command(self, command: str, args: list[Any] = []) -> None:742567 + def _write_command(self, command: str, args: list[Any] = None) -> None:743568 + if args is None:744569 + args = []745570 | parts = [command]746 |747note: This is an unsafe fix and may change runtime behavior748749UP031 Use format specifiers instead of percent format750 --> mpd/base.py:648:25751 |752646 | self.disconnect()753647 | raise ConnectionError(754648 | / "Connection lost while reading binary data: "755649 | | "expected %d bytes, got %d" % (chunk_size, len(value))756 | |___________________________________________________^757650 | )758 |759help: Replace with format specifiers760761UP028 Replace `yield` over `for` loop with `yield from`762 --> mpd/base.py:735:13763 |764733 | ) -> Iterator[dict[str, str]]:765734 | try:766735 | / for item in iterator:767736 | | yield item768 | |__________________________^769737 | finally:770738 | self._iterating = False771 |772help: Replace with `yield from`773 |774734 | try:775 - for item in iterator:776 - yield item777735 + yield from iterator778736 | finally:779 |780note: This is an unsafe fix and may change runtime behavior781782RUF059 Unpacked variable `canonname` is never used783 --> mpd/base.py:775:34784 |785773 | socket.AI_ADDRCONFIG,786774 | ):787775 | af, socktype, proto, canonname, sa = res788 | ^^^^^^^^^789776 | sock = None790777 | try:791 |792help: Prefix it with an underscore or any other dummy variable pattern793 |794774 | ):795 - af, socktype, proto, canonname, sa = res796775 + af, socktype, proto, _canonname, sa = res797776 | sock = None798 |799note: This is an unsafe fix and may change runtime behavior800801UP031 Use format specifiers instead of percent format802 --> mpd/tests.py:1269:24803 |8041267 | next_write = self._expectations[0][0][0]8051268 | except IndexError:8061269 | self.error("Data written to mock even though none expected: %r" % data)807 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^8081270 | if next_write == data:8091271 | self._expectations[0][0].pop(0)810 |811help: Replace with format specifiers812 |8131268 | except IndexError:814 - self.error("Data written to mock even though none expected: %r" % data)8151269 + self.error("Data written to mock even though none expected: {!r}".format(data))8161270 | if next_write == data:817 |818note: This is an unsafe fix and may change runtime behavior819820UP031 Use format specifiers instead of percent format821 --> mpd/tests.py:1274:24822 |8231272 | self._feed()8241273 | else:8251274 | self.error("Mock got %r, expected %r" % (data, next_write))826 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^8271275 |8281276 | def close(self) -> None:829 |830help: Replace with format specifiers831 |8321273 | else:833 - self.error("Mock got %r, expected %r" % (data, next_write))8341274 + self.error("Mock got {!r}, expected {!r}".format(data, next_write))8351275 |836 |837note: This is an unsafe fix and may change runtime behavior838839B006 Do not use mutable data structures for argument defaults840 --> mpd/twisted.py:153:47841 |842151 | @lock843152 | def _execute(844153 | self, command: str, args: list[str] = [], parser: Callable | None = None845 | ^^846154 | ) -> defer.Deferred:847155 | # close or kill command in command list not allowed848 |849help: Replace with `None`; initialize within function850 |851152 | def _execute(852 - self, command: str, args: list[str] = [], parser: Callable | None = None853153 + self, command: str, args: list[str] = None, parser: Callable | None = None854154 | ) -> defer.Deferred:855155 | # close or kill command in command list not allowed856156 + if args is None:857157 + args = []858158 | if self._in_command_list and self._lookup_callback(parser) is self.NOOP:859 |860note: This is an unsafe fix and may change runtime behavior861862B006 Do not use mutable data structures for argument defaults863 --> mpd/twisted.py:178:63864 |865176 | return deferred866177 |867178 | def _create_command(self, command: str, args: list[str] = []) -> bytes:868 | ^^869179 | # XXX: this function should be generalized in future. There exists870180 | # almost identical code in ``MPDClient._write_command``, with the871 |872help: Replace with `None`; initialize within function873 |874177 |875 - def _create_command(self, command: str, args: list[str] = []) -> bytes:876178 + def _create_command(self, command: str, args: list[str] = None) -> bytes:877179 | # XXX: this function should be generalized in future. There exists878180 | # almost identical code in ``MPDClient._write_command``, with the879181 | # difference that it's using ``encode_str`` for text arguments.880182 + if args is None:881183 + args = []882184 | parts = [command]883 |884note: This is an unsafe fix and may change runtime behavior885886B006 Do not use mutable data structures for argument defaults887 --> mpd/twisted.py:195:62888 |889193 | return " ".join(parts).encode("utf-8")890194 |891195 | def _write_command(self, command: str, args: list[str] = []) -> None:892 | ^^893196 | self.sendLine(self._create_command(command, args))894 |895help: Replace with `None`; initialize within function896 |897194 |898 - def _write_command(self, command: str, args: list[str] = []) -> None:899195 + def _write_command(self, command: str, args: list[str] = None) -> None:900196 + if args is None:901197 + args = []902198 | self.sendLine(self._create_command(command, args))903 |904note: This is an unsafe fix and may change runtime behavior905906Found 298 errors (242 fixed, 56 remaining).90733 unsafe fixes available with `--fix --unsafe-fixes`.908909traversed 45 files910emitted 18 files for processing911formatted 0 files (14 changed) in 180ms912Error: failed to finalise formatting: formatting failures detected