You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that Python 3.8 has added the walrus operator :=, it would make more sense to override that (instead of left-shift <<) to indicate env-assignment in let, do, and similar constructs. It would also help make IDEs happy, because := is a name-binding operator also in standard Python.
The rules would remain the same they are now (as of v0.14.3 and v0.15.0): when a name := value operation is encountered, if the context allows an env-assignment, then it is an env-assignment; otherwise leave it unprocessed, delegating to the standard meaning of := (just like we now, somewhat less sensibly, delegate to the standard meaning of <<).
Doing this will remove the need for noqa: F821 for names declared in let and do expressions, as well as allow the Lispy dialect (variant of Lispython) to work without triggering any undefined-name errors in static code analyzers for standard Python, such as flake8.
We could add name := value now as an alternative syntax, and deprecate the old syntax name << value once Python 3.8 becomes the minimum supported version. See #1 for the language version support schedule.
Note to self: To get started on this, grep the codebase for envassign and LShift. These are already handled centrally, so the required changes should be rather minor. We have a version-sensitive wrapper for NamedExpr in unpythonic.syntax.astcompat that will simply not match anything in 3.6 and 3.7.
The text was updated successfully, but these errors were encountered:
Now that Python 3.8 has added the walrus operator
:=
, it would make more sense to override that (instead of left-shift<<
) to indicate env-assignment inlet
,do
, and similar constructs. It would also help make IDEs happy, because:=
is a name-binding operator also in standard Python.The rules would remain the same they are now (as of v0.14.3 and v0.15.0): when a
name := value
operation is encountered, if the context allows an env-assignment, then it is an env-assignment; otherwise leave it unprocessed, delegating to the standard meaning of:=
(just like we now, somewhat less sensibly, delegate to the standard meaning of<<
).Doing this will remove the need for
noqa: F821
for names declared inlet
anddo
expressions, as well as allow theLispy
dialect (variant of Lispython) to work without triggering any undefined-name errors in static code analyzers for standard Python, such asflake8
.We could add
name := value
now as an alternative syntax, and deprecate the old syntaxname << value
once Python 3.8 becomes the minimum supported version. See #1 for the language version support schedule.Note to self: To get started on this, grep the codebase for
envassign
andLShift
. These are already handled centrally, so the required changes should be rather minor. We have a version-sensitive wrapper forNamedExpr
inunpythonic.syntax.astcompat
that will simply not match anything in 3.6 and 3.7.The text was updated successfully, but these errors were encountered: