Black: Black adds unnecessary parentheses around tuples of one element

Created on 20 Jun 2019  路  3Comments  路  Source: psf/black

Operating system: Ubuntu 19.04
Python version: 3.7.2
Black version: 19.3b0
Does also happen on master: yes

Black forces the use of parentheses on tuples of one element without parentheses. Check the black diff below:

class LivenessProbe(View):
"""Liveness probe handler."""
-    methods = "GET",
+    methods = ("GET",)
def dispatch_request(self) -> Response:

Most helpful comment

I'd say this is a feature, not a bug. A single comma is easy to miss, and the parentheses make it clearer that it's a tuple.

All 3 comments

I'd say this is a feature, not a bug. A single comma is easy to miss, and the parentheses make it clearer that it's a tuple.

The fact that methods = "GET", is valid python syntax is incredibly annoying. It causes so many hard-to-find bugs and is basically useless.

No action required here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

uranusjr picture uranusjr  路  3Comments

JelleZijlstra picture JelleZijlstra  路  3Comments

bhearsum picture bhearsum  路  3Comments

dimaqq picture dimaqq  路  3Comments

testvinder picture testvinder  路  3Comments