| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b411f6c commit 6737453
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,4 +13,5 @@ | |||
| 13 | 13 | # limitations under the License. | |
| 14 | 14 | docker: | |
| 15 | 15 | image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest | |
| 16 | - digest: sha256:266a3407f0bb34374f49b6556ee20ee819374587246dcc19405b502ec70113b6 | ||
| 16 | + digest: sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416 | ||
| 17 | + # created: 2022-04-20T23:42:53.970438194Z | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,8 @@ | |||
| 25 | 25 | import nox | |
| 26 | 26 | ||
| 27 | 27 | BLACK_VERSION = "black==22.3.0" | |
| 28 | - BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] | ||
| 28 | + ISORT_VERSION = "isort==5.10.1" | ||
| 29 | + LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] | ||
| 29 | 30 | ||
| 30 | 31 | DEFAULT_PYTHON_VERSION = "3.8" | |
| 31 | 32 | ||
@@ -83,7 +84,7 @@ def lint(session): | |||
| 83 | 84 | session.run( | |
| 84 | 85 | "black", | |
| 85 | 86 | "--check", | |
| 86 | - *BLACK_PATHS, | ||
| 87 | + *LINT_PATHS, | ||
| 87 | 88 | ) | |
| 88 | 89 | session.run("flake8", "google", "tests") | |
| 89 | 90 | ||
@@ -94,7 +95,27 @@ def blacken(session): | |||
| 94 | 95 | session.install(BLACK_VERSION) | |
| 95 | 96 | session.run( | |
| 96 | 97 | "black", | |
| 97 | - *BLACK_PATHS, | ||
| 98 | + *LINT_PATHS, | ||
| 99 | + ) | ||
| 100 | + | ||
| 101 | + | ||
| 102 | + @nox.session(python=DEFAULT_PYTHON_VERSION) | ||
| 103 | + def format(session): | ||
| 104 | + """ | ||
| 105 | + Run isort to sort imports. Then run black | ||
| 106 | + to format code to uniform standard. | ||
| 107 | + """ | ||
| 108 | + session.install(BLACK_VERSION, ISORT_VERSION) | ||
| 109 | + # Use the --fss option to sort imports using strict alphabetical order. | ||
| 110 | + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections | ||
| 111 | + session.run( | ||
| 112 | + "isort", | ||
| 113 | + "--fss", | ||
| 114 | + *LINT_PATHS, | ||
| 115 | + ) | ||
| 116 | + session.run( | ||
| 117 | + "black", | ||
| 118 | + *LINT_PATHS, | ||
| 98 | 119 | ) | |
| 99 | 120 | ||
| 100 | 121 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,7 @@ | |||
| 30 | 30 | # WARNING - WARNING - WARNING - WARNING - WARNING | |
| 31 | 31 | ||
| 32 | 32 | BLACK_VERSION = "black==22.3.0" | |
| 33 | + ISORT_VERSION = "isort==5.10.1" | ||
| 33 | 34 | ||
| 34 | 35 | # Copy `noxfile_config.py` to your directory and modify it instead. | |
| 35 | 36 | ||
@@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None: | |||
| 168 | 169 | ||
| 169 | 170 | @nox.session | |
| 170 | 171 | def blacken(session: nox.sessions.Session) -> None: | |
| 172 | + """Run black. Format code to uniform standard.""" | ||
| 171 | 173 | session.install(BLACK_VERSION) | |
| 172 | 174 | python_files = [path for path in os.listdir(".") if path.endswith(".py")] | |
| 173 | 175 | ||
| 174 | 176 | session.run("black", *python_files) | |
| 175 | 177 | ||
| 176 | 178 | ||
| 179 | + # | ||
| 180 | + # format = isort + black | ||
| 181 | + # | ||
| 182 | + | ||
| 183 | + @nox.session | ||
| 184 | + def format(session: nox.sessions.Session) -> None: | ||
| 185 | + """ | ||
| 186 | + Run isort to sort imports. Then run black | ||
| 187 | + to format code to uniform standard. | ||
| 188 | + """ | ||
| 189 | + session.install(BLACK_VERSION, ISORT_VERSION) | ||
| 190 | + python_files = [path for path in os.listdir(".") if path.endswith(".py")] | ||
| 191 | + | ||
| 192 | + # Use the --fss option to sort imports using strict alphabetical order. | ||
| 193 | + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections | ||
| 194 | + session.run("isort", "--fss", *python_files) | ||
| 195 | + session.run("black", *python_files) | ||
| 196 | + | ||
| 197 | + | ||
| 177 | 198 | # | |
| 178 | 199 | # Sample Tests | |
| 179 | 200 | # | |
| Back | FazBrowse Home | New Git URL |
0 commit comments