Skip to content

project: fix black + python#2316

Merged
ultrabug merged 1 commit into
ultrabug:masterfrom
lasers:black
Jan 29, 2026
Merged

project: fix black + python#2316
ultrabug merged 1 commit into
ultrabug:masterfrom
lasers:black

Conversation

@lasers

@lasers lasers commented Jan 20, 2026

Copy link
Copy Markdown
Contributor
  1. I missed one thing in dropping python 3.9. Sorry.

  2. Black released a new version. I addressed this change early.

remove_parens_from_assignment_lhs: Remove unnecessary parentheses from the left-hand
side of assignments while preserving magic trailing commas and intentional multiline
formatting

However, we all are running different black versions. There is a new change that could cause unwanted formatting issues repeatedly due to older black version (in editors auto formatting) and such. Because I addressed unnecessary parentheses early, the remaining new changes is just two files below.

--- /home/runner/work/py3status/py3status/py3status/modules/glpi.py	2026-01-20 15:13:49.267019+00:00
+++ /home/runner/work/py3status/py3status/py3status/modules/glpi.py	2026-01-20 15:14:14.565354+00:00
@@ -57,15 +57,13 @@
             passwd=self.password,
             db=self.db,
             connect_timeout=self.timeout,
         )
         mycr = mydb.cursor()
-        mycr.execute(
-            """select count(*)
+        mycr.execute("""select count(*)
                         from glpi_tickets
-                        where closedate is NULL and solvedate is NULL;"""
-        )
+                        where closedate is NULL and solvedate is NULL;""")
         row = mycr.fetchone()
         if row:
             open_tickets = int(row[0])
             if open_tickets > self.critical:
                 response.update({"color": self.py3.COLOR_BAD})

And...

--- /home/runner/work/py3status/py3status/py3status/modules/rt.py	2026-01-20 15:13:49.270019+00:00
+++ /home/runner/work/py3status/py3status/py3status/modules/rt.py	2026-01-20 15:14:15.272437+00:00
@@ -64,21 +64,19 @@
             passwd=self.password,
             db=self.db,
             connect_timeout=self.timeout,
         )
         mycr = mydb.cursor()
-        mycr.execute(
-            """select q.Name as queue, coalesce(total,0) as total
+        mycr.execute("""select q.Name as queue, coalesce(total,0) as total
             from Queues as q
             left join (
                 select t.Queue as queue, count(t.id) as total
                 from Tickets as t
                 where Status = 'new' or Status = 'open' or Status = 'stalled'
                 group by t.Queue)
             as s on s.Queue = q.id
-            group by q.Name;"""
-        )
+            group by q.Name;""")
         for row in mycr.fetchall():
             queue, nb_tickets = row
             if queue == "___Approvals":
                 continue
             tickets[queue] = nb_tickets

If you want me to fix them too (and drop pinned black), I can. Some editors will run older black on save and revert the formats... is which why I think it's okay to pin black for a while. Also, because of git pre-push hook too.

@ultrabug

Copy link
Copy Markdown
Owner

@lasers thx. I'd rather pin and fix for newer black versions than pin an older version please?

@lasers

lasers commented Jan 20, 2026

Copy link
Copy Markdown
Contributor Author
fedora - black, 24.4.2
archlinux - black, 25.12.0

OK on fixing for latest black.

@ultrabug

Copy link
Copy Markdown
Owner

@lasers sorry I was not clear I meant to pin a "higher than" black version in the requirements to make it clear that we expect at least this version

@lasers

lasers commented Jan 28, 2026

Copy link
Copy Markdown
Contributor Author

@ultrabug My fault anyway for assuming.

Also, I believe I found a better solution that doesn't involve pinning newer black. Just adding # fmt: {off,on} to those two modules will make black (of any last few versions) work fine. I prefer this approach over requiring contributors to use newer black immediately.

The plan would be to revisit several # fmt: {off,on} again long after black 26.1.0 landed in several (stable) distributions and to see if black still use this approach. I also assume it is more for docstrings than sql commands inside parentheses.

EDIT: Need to know your choice now with this alternative solution now included.
Approach 1) Pin newer black. No fmt.
Approach 2) No black pinning. Use fmt off/on.

@ultrabug

Copy link
Copy Markdown
Owner

Sounds reasonable, thank you

@ultrabug
ultrabug merged commit bdc8930 into ultrabug:master Jan 29, 2026
7 checks passed
@lasers
lasers deleted the black branch January 29, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants