Repository: jupyterhub/nativeauthenticator (language: python)

Issue:
Smaller tweaks from pre-commit autoformatting hooks
We have adopted pre-commit hooks to do autoformatting work and some linting checks in most active projects in the JupyterHub org. I'd like to propose we do the same in nativeauthenticator.

- I find the requirements-txt-fixer hook to make the code more readable even though it's more verbose. I like especially how it groups the python standard library imports in the top separate from the third party imports and the local imports.
- I find the `pyupgrade` hook to migrate old python syntax patterns to modern syntax patterns quite helpful as well.

In this PR, I've applied all but the `black` autoformatting hook. I think it's better to do that in a dedicated PR to make the review of the changes made from the other hooks easier. `black` will change a lot more lines than the other hooks.

### Related

- https://github.com/jupyterhub/team-compass/issues/454
- https://github.com/jupyterhub/team-compass/issues/453
- https://github.com/jupyterhub/team-compass/issues/379
- https://github.com/jupyterhub/team-compass/issues/155
pre-commit: apply black formatting
This is a followup PR to #173 that added the .pre-commit-config.yaml file that also defines that `black` should run. I wanted to make the changes made by black into a separate PR as they are harder to overview and would otherwise clutter the changes observed in #173.

To review this, I suggest looking at the individual commits in order.

Also note that string normalization to use `"` systematically instead of a mix of `"` and `'` is something that we can opt to not do while still being in compliance with general practices in the JupyterHub org, where we sometimes have enforced it and sometimes haven't enforced it. Due to that, I made it a separate commit that can be easily reviewed/removed from this PR.

With regards to string normalization, I suggest we go with whatever your gut feeling tells you at this point in time @lambdaTotoro.


Discussion / hints:
Sure, some auto-format couldn't hurt. And I generally approve of NativeAuthenticator being more in line with other projects in the Jupyter ecosystem. 

Is this PR ready to merge from your end? 
@lambdaTotoro nice! Yepp this is ready from my end!
Wonderful. Merging now. 


Fix patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2b32d49..21d10d5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -22,6 +22,24 @@ And then installing Native Authenticator from master branch:
 pip install -e .
 ```
 
+### Configure pre-commit
+
+[`pre-commit`](https://pre-commit.com/) is a tool we use to validate code and
+autoformat it. The kind of validation and auto formatting can be inspected via
+the `.pre-commit-config.yaml` file.
+
+As the name implies, `pre-commit` can be configured to run its validation and
+auto formatting just before you make a commit. By configuring it to do so, you
+can avoid having to have a separate commit later that applies auto formatting.
+
+To configure `pre-commit` to run act before you commit, you can run the
+following command from the root of this repository next to the
+`.pre-commit-config.yaml` file.
+
+```shell
+pre-commit install
+```
+
 ### Running your local project
 
 For developing the Native Authenticator, you can start a JupyterHub server using `dev-jupyterhub_config.py`.
diff --git a/dev-requirements.txt b/dev-requirements.txt
index c32ed72..480cdb2 100644
--- a/dev-requirements.txt
+++ b/dev-requirements.txt
@@ -3,5 +3,6 @@ codecov
 flake8
 notebook>=6.4.1
 onetimepass
+pre-commit
 pytest >= 3.7
 pytest-asyncio


Test patch:
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 546b524..f9dad9f 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -5,32 +5,29 @@ name: Test
 
 on:
   pull_request:
+    paths-ignore:
+      - "docs/**"
+      - "**.md"
+      - "**.rst"
+      - ".github/workflows/*"
+      - "!.github/workflows/test.yaml"
   push:
+    paths-ignore:
+      - "docs/**"
+      - "**.md"
+      - "**.rst"
+      - ".github/workflows/*"
+      - "!.github/workflows/test.yaml"
+    branches-ignore:
+      - "dependabot/**"
+      - "pre-commit-ci-update-config"
   workflow_dispatch:
 
 jobs:
-  flake8:
-    name: Run flake8
-    runs-on: ubuntu-20.04
-
-    steps:
-      - uses: actions/checkout@v2
-      - uses: actions/setup-python@v2
-        with:
-          python-version: "3.9"
-
-      - name: Install Python dependencies
-        run: |
-          pip install --no-cache-dir -r dev-requirements.txt
-          pip install .
-
-      - name: Run tests
-        run: |
-          flake8
-
   pytest:
     name: Run pytests
     runs-on: ubuntu-20.04
+
     strategy:
       fail-fast: false
       matrix: