Feature or enhancement
Proposal:
Lib/asyncio/subprocess.py contains two protocol_factory = lambda: ...
assignments that violate PEP 8 recommendation E731:
Always use a def statement instead of an assignment statement that binds a lambda expression directly to an identifier
# Lib/asyncio/subprocess.py:209
async def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None,
limit=streams._DEFAULT_LIMIT, **kwds):
loop = events.get_running_loop()
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
loop=loop)
...
# Lib/asyncio/subprocess.py:222
async def create_subprocess_exec(program, *args, stdin=None, stdout=None,
stderr=None, limit=streams._DEFAULT_LIMIT,
**kwds):
loop = events.get_running_loop()
protocol_factory = lambda: SubprocessStreamProtocol(limit=limit,
loop=loop)
...
Proposed change:
Replace both with proper def statements:
def protocol_factory():
return SubprocessStreamProtocol(limit=limit, loop=loop)
Sources:
- https://peps.python.org/pep-0008/#programming-recommendations:~:text=Always%20use%20a%20def%20statement%20instead%20of%20an%20assignment%20statement%20that%20binds%20a%20lambda%20expression%20directly%20to%20an%20identifier%3A
- https://docs.astral.sh/ruff/rules/lambda-assignment/
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs
Feature or enhancement
Proposal:
Lib/asyncio/subprocess.pycontains twoprotocol_factory = lambda: ...assignments that violate PEP 8 recommendation E731:
Proposed change:
Replace both with proper def statements:
Sources:
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
Linked PRs