From 0510ef65db3026d6eceeb10520b52e48ca9aa7d7 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Tue, 8 Dec 2020 14:46:26 -0800 Subject: [PATCH] chore: add pre-commit hook (#57) --- packages/google-cloud-container/.coveragerc | 15 +++++++-------- .../.pre-commit-config.yaml | 17 +++++++++++++++++ .../google-cloud-container/CONTRIBUTING.rst | 10 ++++++++++ packages/google-cloud-container/docs/conf.py | 5 +---- packages/google-cloud-container/noxfile.py | 5 ++--- packages/google-cloud-container/synth.metadata | 5 +++-- 6 files changed, 40 insertions(+), 17 deletions(-) create mode 100644 packages/google-cloud-container/.pre-commit-config.yaml diff --git a/packages/google-cloud-container/.coveragerc b/packages/google-cloud-container/.coveragerc index dd39c8546c41..07731a53149f 100644 --- a/packages/google-cloud-container/.coveragerc +++ b/packages/google-cloud-container/.coveragerc @@ -14,22 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Generated by synthtool. DO NOT EDIT! [run] branch = True [report] fail_under = 100 show_missing = True +omit = + google/cloud/container/__init__.py exclude_lines = # Re-enable the standard pragma pragma: NO COVER # Ignore debug-only repr def __repr__ - # Ignore abstract methods - raise NotImplementedError -omit = - */gapic/*.py - */proto/*.py - */core/*.py - */site-packages/*.py \ No newline at end of file + # Ignore pkg_resources exceptions. + # This is added at the module level as a safeguard for if someone + # generates the code and tries to run it without pip installing. This + # makes it virtually impossible to test properly. + except pkg_resources.DistributionNotFound \ No newline at end of file diff --git a/packages/google-cloud-container/.pre-commit-config.yaml b/packages/google-cloud-container/.pre-commit-config.yaml new file mode 100644 index 000000000000..6ad83346e261 --- /dev/null +++ b/packages/google-cloud-container/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml +- repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 diff --git a/packages/google-cloud-container/CONTRIBUTING.rst b/packages/google-cloud-container/CONTRIBUTING.rst index f9ddc489c7d0..133de07b74a8 100644 --- a/packages/google-cloud-container/CONTRIBUTING.rst +++ b/packages/google-cloud-container/CONTRIBUTING.rst @@ -111,6 +111,16 @@ Coding Style should point to the official ``googleapis`` checkout and the the branch should be the main branch on that remote (``master``). +- This repository contains configuration for the + `pre-commit `__ tool, which automates checking + our linters during a commit. If you have it installed on your ``$PATH``, + you can enable enforcing those checks via: + +.. code-block:: bash + + $ pre-commit install + pre-commit installed at .git/hooks/pre-commit + Exceptions to PEP8: - Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for diff --git a/packages/google-cloud-container/docs/conf.py b/packages/google-cloud-container/docs/conf.py index 67b6599e48af..6cbe9eac6a81 100644 --- a/packages/google-cloud-container/docs/conf.py +++ b/packages/google-cloud-container/docs/conf.py @@ -346,10 +346,7 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), - "google-auth": ( - "https://googleapis.dev/python/google-auth/latest/index.html", - None, - ), + "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), diff --git a/packages/google-cloud-container/noxfile.py b/packages/google-cloud-container/noxfile.py index 548b398c168f..bf63a134b50d 100644 --- a/packages/google-cloud-container/noxfile.py +++ b/packages/google-cloud-container/noxfile.py @@ -81,9 +81,8 @@ def default(session): session.run( "py.test", "--quiet", - "--cov=google.cloud.container", - "--cov=google.cloud", - "--cov=tests.unit", + "--cov=google/cloud", + "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", "--cov-report=", diff --git a/packages/google-cloud-container/synth.metadata b/packages/google-cloud-container/synth.metadata index 4cd79d6a1f24..d305b158c383 100644 --- a/packages/google-cloud-container/synth.metadata +++ b/packages/google-cloud-container/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-container.git", - "sha": "20401fb2dfa4ac59d385926d345db979473c4688" + "sha": "6a0fef7f30976357cc9f42c0213931d1a2c76eac" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "9a7d9fbb7045c34c9d3d22c1ff766eeae51f04c9" + "sha": "f94318521f63085b9ccb43d42af89f153fb39f15" } } ], @@ -87,6 +87,7 @@ ".kokoro/test-samples.sh", ".kokoro/trampoline.sh", ".kokoro/trampoline_v2.sh", + ".pre-commit-config.yaml", ".trampolinerc", "CODE_OF_CONDUCT.md", "CONTRIBUTING.rst",