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

Clean code #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Clean code #1

wants to merge 2 commits into from

Conversation

joamatab
Copy link

  • simpler code with fstrings
  • run black

@joamatab joamatab changed the title Clean code2 Clean code Jun 10, 2022
@atait
Copy link
Owner

atait commented Jun 11, 2022

1

I prefer this pattern when there is hierarchy equivalence. It makes more sense

if thing:
    return 1
else:
    return 2

The fall through pattern makes more sense when the branches are not logically balanced

if anomaly:
    return None
return 2

Does black have a setting to ignore these?

2

In cases where there are one-line comments, style A

some = code  # this does nothing

style B

# this does nothing
some = code

style C

some = (
    code
)  # this does nothing

The point of style A is for that comment to pertain to that line only, rather than any following lines, which happens in style B. I think style C is the worst. Is there is a way for black to ignore comments when calculating line lengths? Otherwise, can you change these instances to style B?

@joamatab joamatab mentioned this pull request Jun 11, 2022
@joamatab
Copy link
Author

sure, let me send them in separate PRs

@atait
Copy link
Owner

atait commented Jun 14, 2022

Could you send them as new commits on this PR? Makes things cleaner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants