
Since power operators almost always have the highest binding power in expressions, it's often more readable to hug it with its operands. The main exception to this is when its operands are non-trivial in which case the power operator will not hug, the rule for this is the following: > For power ops, an operand is considered "simple" if it's only a NAME, numeric CONSTANT, or attribute access (chained attribute access is allowed), with or without a preceding unary operator. Fixes GH-538. Closes GH-2095. diff-shades results: https://gist.github.com/ichard26/ca6c6ad4bd1de5152d95418c8645354b Co-authored-by: Diego <dpalma@evernote.com> Co-authored-by: Felix Hildén <felix.hilden@gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
48 lines
970 B
Python
48 lines
970 B
Python
(a := 1)
|
|
(a := a)
|
|
if (match := pattern.search(data)) is None:
|
|
pass
|
|
if match := pattern.search(data):
|
|
pass
|
|
[y := f(x), y**2, y**3]
|
|
filtered_data = [y for x in data if (y := f(x)) is None]
|
|
(y := f(x))
|
|
y0 = (y1 := f(x))
|
|
foo(x=(y := f(x)))
|
|
|
|
|
|
def foo(answer=(p := 42)):
|
|
pass
|
|
|
|
|
|
def foo(answer: (p := 42) = 5):
|
|
pass
|
|
|
|
|
|
lambda: (x := 1)
|
|
(x := lambda: 1)
|
|
(x := lambda: (y := 1))
|
|
lambda line: (m := re.match(pattern, line)) and m.group(1)
|
|
x = (y := 0)
|
|
(z := (y := (x := 0)))
|
|
(info := (name, phone, *rest))
|
|
(x := 1, 2)
|
|
(total := total + tax)
|
|
len(lines := f.readlines())
|
|
foo(x := 3, cat="vector")
|
|
foo(cat=(category := "vector"))
|
|
if any(len(longline := l) >= 100 for l in lines):
|
|
print(longline)
|
|
if env_base := os.environ.get("PYTHONUSERBASE", None):
|
|
return env_base
|
|
if self._is_special and (ans := self._check_nans(context=context)):
|
|
return ans
|
|
foo(b := 2, a=1)
|
|
foo((b := 2), a=1)
|
|
foo(c=(b := 2), a=1)
|
|
|
|
while x := f(x):
|
|
pass
|
|
while x := f(x):
|
|
pass
|