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

General maintenance: autoformat, flake8, readme badges, misc in github workflows #208

Merged
merged 11 commits into from
May 5, 2021

Conversation

consideRatio
Copy link
Member

@consideRatio consideRatio commented Jan 29, 2021

General matinenance

  • black autoformatting for python
  • prettier autoformatting for json/yaml/markdown
  • flake8 with relaxed config for static code inspection
  • readme badges
  • color for pytest

Review notes

Only the autoformatting commits for black / prettier are large, but they are only that. Reviewing commit by commit is probably reasonable.

@welcome

This comment has been minimized.

@consideRatio consideRatio changed the title General maintenance: autoformat, flake8, readme badges, color in github workflows General maintenance: autoformat, flake8, readme badges, misc in github workflows Jan 29, 2021
@consideRatio consideRatio mentioned this pull request Jan 30, 2021
13 tasks
@consideRatio consideRatio force-pushed the pr/general-maintenance branch 2 times, most recently from 728fb57 to 83a6e8c Compare January 31, 2021 14:03
@consideRatio
Copy link
Member Author

@rkdarst @mbmilligan @minrk this PR is going stale, could you help nudge this PR towards resolving?

This repo is not the first to have the same kind of changes, but they have been adopted in various other repository within the jupyterhub org.

@rkdarst
Copy link
Contributor

rkdarst commented Mar 3, 2021

We just talked about this in the monthly JupyterHub in HPC meeting. I think we will wait another month for the next meeting, when a few more key people are hopefully here. Development isn't too fast so risk of conflict isn't that great.

But the general feeling is we think it's a good idea because standarizing is more important than our preferences. There's a bit of grumbling about auto-formatting[1][2], but the acceptance is we need to live with it.

Thanks for working through all of this!

[1] For me, the issue is mainly that code should be as readable as possible, and readability can be increased by conveying information in certain types of formatting. Auto-formatters can't understand this. I wrote up this long ago for someone who once auto-formatted all of my code, before black became a thing: http://rkd.zgib.net/wiki/Python/Style .
[2] Another was explaining how to format it locally. I think directing to JH docs is plenty for that, we can handle it later.

@rkdarst
Copy link
Contributor

rkdarst commented Mar 4, 2021

@mbmilligan, if you agree, I guess all of us at the meeting yesterday would say 'let's go ahead and merge'. Anyone else, correct me if I'm wrong.

@consideRatio
Copy link
Member Author

@rkdarst thanks for considering this! I absolutely agree with the feeling it is a compromise on code readability when sections are made with intention for readability.

The key value I find for autoformatting is that they reduce the complexity to review and track changes in PRs as the changes following that can be trusted to only be non-formatting related. This aspect has ended up being practically very relevant for several repo's across the org.

@rcthomas
Copy link
Contributor

@consideRatio @mbmilligan I think at the April HPC call we discussed that if this PR was brought up to date and conflicts resolved then it would be merged. Sound good? I think it's just 2 conflicts that need to be fixed, can you do that @consideRatio? Thanks!

@@ -88,89 +88,98 @@ class BatchSpawnerBase(Spawner):
start_timeout = Integer(300).tag(config=True)

# override default server ip since batch jobs normally running remotely
ip = Unicode("0.0.0.0", help="Address for singleuser server to listen at").tag(config=True)
ip = Unicode("0.0.0.0", help="Address for singleuser server to listen at").tag(
Copy link
Member

Choose a reason for hiding this comment

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

This is an abomination. If black is going to insist on breaking these lines, let's add trailing commas to the argument list so that it doesn't break the .tag(config=True) expression in a way that obscures the method chaining being used.

@mbmilligan
Copy link
Member

Yes, the team agreed that we should go ahead and adopt this workflow. I did a thorough review of the resulting changes and only found one really objectionable antipattern, an example of which is flagged in my comment above. It looks like that can be dealt with by adding some extra trailing commas to the trait definition parameter lists, and I'd like to see that done as part of this PR so we don't neglect it later.

I've systematically added a trailing comma to traitlets where more than
one argument was passed and that had .tag(config=True) suffixed.

This was my understanding of a suggestion made by mbmilligan in this
commits associated PR.

Example:

```python
    # before this commit (with black formatting)
    ip = Unicode("0.0.0.0", help="Address for singleuser server to listen at").tag(
        config=True
    )

    # after this commit (with black formatting)
    ip = Unicode(
    	"0.0.0.0",
	help="Address for singleuser server to listen at",
    ).tag(config=True)

    # independent of this commit
    batch_submit_cmd = Unicode("qsub").tag(config=True)
```
@consideRatio
Copy link
Member Author

consideRatio commented Apr 17, 2021

@rcthomas and @mbmilligan thanks for following up on this! I have reapplied the changes on master and added commit 870eea0 with its comment on what I did to address #208 (comment).

A test failure has shown up, but I could see it in other recent CI failures so it doesn't relate to this PR. I think the test failure is related to jupyterhub 0.9.6 (very old) not pinning its requirement on sqlalchemy hard enough given some more recent change to it (https://pypi.org/project/SQLAlchemy/#history).

While investigating this CI failure I made the CI system not cancel all tests if a single test fails (706c560), and I also made the test run against jupyterhub 1.3.0 (5dde989).

@mbmilligan
Copy link
Member

Thank you for updating the branch. This looks acceptable to me now.

@mbmilligan mbmilligan merged commit 1decdf2 into jupyterhub:master May 5, 2021
@welcome
Copy link

welcome bot commented May 5, 2021

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@consideRatio
Copy link
Member Author

Thanks @mbmilligan!

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

Successfully merging this pull request may close these issues.

4 participants