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

Sample code for the Click article #415

Merged
merged 5 commits into from
Aug 17, 2023
Merged

Sample code for the Click article #415

merged 5 commits into from
Aug 17, 2023

Conversation

lpozo
Copy link
Contributor

@lpozo lpozo commented Jul 21, 2023

Where to put new files:

  • New files should go into a top-level subfolder, named after the article slug. For example: my-awesome-article

How to merge your changes:

  1. Make sure the CI code style tests all pass (+ run the automatic code formatter if necessary).
  2. Find an RP Team member on Slack and ask them to review & approve your PR.
  3. Once the PR has one positive ("approved") review, GitHub lets you merge the PR.
  4. 🎉

def cli():
a = click.prompt("Enter an integer", type=click.INT, default=0)
b = click.prompt("Enter another integer", type=click.INT, default=0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this extra blank line here?

cli.add_command(commands.sub)
cli.add_command(commands.mul)
cli.add_command(commands.div)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be two blank lines here for consistency.

cli.add_command(commands.sub)
cli.add_command(commands.mul)
cli.add_command(commands.div)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be two blank lines here as well?

@@ -0,0 +1,40 @@
# nasa.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is redundant.

Comment on lines 5 to 8
@click.option(
"--name",
multiple=True,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collapse these into a single line?

Comment on lines 26 to 27
if i < len(paths) - 1:
click.echo()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change:

Suggested change
if i < len(paths) - 1:
click.echo()
if i < len(paths) - 1:
click.echo("" if long else "\n")
elif not long:
click.echo()

for entry in path.iterdir():
entry_output = build_output(entry, long)
click.echo(f"{entry_output:{len(entry_output) + 5}}", nl=long)
click.echo("\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change:

Suggested change
click.echo("\n")
if i < len(paths) - 1:
click.echo("" if long else "\n")
elif not long:
click.echo()

for entry in path.iterdir():
entry_output = build_output(entry, long)
click.echo(f"{entry_output:{len(entry_output) + 5}}", nl=long)
click.echo("\n")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change:

Suggested change
click.echo("\n")
if i < len(paths) - 1:
click.echo("" if long else "\n")
elif not long:
click.echo()

Copy link
Contributor

@bzaczynski bzaczynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lpozo Hey, I'm approving this PR but I wanted to let you know that I left some suggestions for you.

@KateFinegan KateFinegan merged commit e5599b7 into master Aug 17, 2023
1 check passed
@KateFinegan KateFinegan deleted the python-click branch August 17, 2023 19:55
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.

3 participants