Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce level of nesting #128739

Closed
byBenPuls opened this issue Jan 11, 2025 · 1 comment
Closed

Reduce level of nesting #128739

byBenPuls opened this issue Jan 11, 2025 · 1 comment
Labels
type-feature A feature request or enhancement

Comments

@byBenPuls
Copy link

byBenPuls commented Jan 11, 2025

Feature or enhancement

Proposal:

Make code easier to read by reducing the level of nesting. High levels of nesting make code more confusing and less readable.
For example:

if process.returncode == 0:
    return stdout.decode(*DECODE_ARGS)
else:
    raise CalledProcessError(
        process.returncode, args,
        stdout.decode(*DECODE_ARGS), stderr.decode(*DECODE_ARGS)
    )

We can remove else, simplify the code:

if process.returncode == 0:
    return stdout.decode(*DECODE_ARGS)
raise CalledProcessError(
    process.returncode, args,
    stdout.decode(*DECODE_ARGS), stderr.decode(*DECODE_ARGS)
)

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

@byBenPuls byBenPuls added the type-feature A feature request or enhancement label Jan 11, 2025
@terryjreedy
Copy link
Member

I prefer the else at making the alternation clearer at a glance.

@terryjreedy terryjreedy closed this as not planned Won't fix, can't repro, duplicate, stale Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants