From facee4cc1ea096cd8bcc008bb85929daa7c414c0 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Fri, 13 Aug 2021 10:34:06 -0400 Subject: [PATCH] chore: drop mention of Python 2.7 from templates (#1173) Install async test dependencies unconditionally. Drop unused 'samples' session. Samples are tested via separate noxfiles in all repos which have them. Closes #1118. Co-authored-by: Anthonios Partheniou --- synthtool/gcp/common.py | 8 -------- .../templates/python_library/noxfile.py.j2 | 20 ++----------------- .../templates/install_deps.tmpl.rst | 2 +- .../templates/python_samples/noxfile.py.j2 | 6 +++--- synthtool/languages/python.py | 6 +++--- 5 files changed, 9 insertions(+), 33 deletions(-) diff --git a/synthtool/gcp/common.py b/synthtool/gcp/common.py index 4f4532031..1f54ad3f4 100644 --- a/synthtool/gcp/common.py +++ b/synthtool/gcp/common.py @@ -225,17 +225,9 @@ def py_library(self, **kwargs) -> Path: kwargs["default_python_version"] = "3.8" if "unit_test_python_versions" not in kwargs: kwargs["unit_test_python_versions"] = ["3.6", "3.7", "3.8", "3.9"] - if "microgenerator" not in kwargs: - kwargs["unit_test_python_versions"] = ["2.7"] + kwargs[ - "unit_test_python_versions" - ] if "system_test_python_versions" not in kwargs: kwargs["system_test_python_versions"] = ["3.8"] - if "microgenerator" not in kwargs: - kwargs["system_test_python_versions"] = ["2.7"] + kwargs[ - "system_test_python_versions" - ] # If cov_level is not given, set it to None. if "cov_level" not in kwargs: diff --git a/synthtool/gcp/templates/python_library/noxfile.py.j2 b/synthtool/gcp/templates/python_library/noxfile.py.j2 index 8b3197d09..cb6672d4b 100644 --- a/synthtool/gcp/templates/python_library/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_library/noxfile.py.j2 @@ -87,10 +87,8 @@ def default(session): constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - {%- if microgenerator %} - session.install("asyncmock", "pytest-asyncio", "-c", constraints_path) - {% endif %} - session.install("mock", "pytest", "pytest-cov", {% for d in unit_test_external_dependencies %}"{{d}}",{% endfor %} "-c", constraints_path) + session.install("mock", "asyncmock", "pytest", "pytest-cov", "pytest-asyncio", "-c", constraints_path) + {% for d in unit_test_external_dependencies %}session.install("{{d}}", "-c", constraints_path){% endfor %} {% for dependency in unit_test_local_dependencies %}session.install("-e", "{{dependency}}", "-c", constraints_path) {% endfor %} {% for dependency in unit_test_dependencies %}session.install("-e", "{{dependency}}", "-c", constraints_path){% endfor %} @@ -192,20 +190,6 @@ def system(session): *session.posargs ) -{% if samples_test %} -@nox.session(python=["2.7", "3.7"]) -def samples(session): - requirements_path = os.path.join("samples", "requirements.txt") - requirements_exists = os.path.exists(requirements_path) - - session.install("mock", "pytest") - if requirements_exists: - session.install("-r", requirements_path) - session.install("-e", ".") - - session.run("py.test", "--quiet", "samples", *session.posargs) -{% endif %} - @nox.session(python=DEFAULT_PYTHON_VERSION) def cover(session): """Run the final coverage report. diff --git a/synthtool/gcp/templates/python_library/scripts/readme-gen/templates/install_deps.tmpl.rst b/synthtool/gcp/templates/python_library/scripts/readme-gen/templates/install_deps.tmpl.rst index a0406dba8..275d64989 100644 --- a/synthtool/gcp/templates/python_library/scripts/readme-gen/templates/install_deps.tmpl.rst +++ b/synthtool/gcp/templates/python_library/scripts/readme-gen/templates/install_deps.tmpl.rst @@ -12,7 +12,7 @@ Install Dependencies .. _Python Development Environment Setup Guide: https://cloud.google.com/python/setup -#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+. +#. Create a virtualenv. Samples are compatible with Python 3.6+. .. code-block:: bash diff --git a/synthtool/gcp/templates/python_samples/noxfile.py.j2 b/synthtool/gcp/templates/python_samples/noxfile.py.j2 index 125bb619c..e73436a15 100644 --- a/synthtool/gcp/templates/python_samples/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_samples/noxfile.py.j2 @@ -39,7 +39,7 @@ BLACK_VERSION = "black==19.10b0" TEST_CONFIG = { # You can opt out from the test for specific Python versions. - 'ignored_versions': ["2.7"], + 'ignored_versions': [], # Old samples are opted out of enforcing Python type hints # All new samples should feature them @@ -88,8 +88,8 @@ def get_pytest_env_vars() -> Dict[str, str]: # DO NOT EDIT - automatically generated. -# All versions used to tested samples. -ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"] +# All versions used to test samples. +ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] # Any default versions that should be ignored. IGNORED_VERSIONS = TEST_CONFIG['ignored_versions'] diff --git a/synthtool/languages/python.py b/synthtool/languages/python.py index ff4c467e2..266aeb64d 100644 --- a/synthtool/languages/python.py +++ b/synthtool/languages/python.py @@ -15,7 +15,7 @@ import re import sys from pathlib import Path -from typing import Any, Dict +from typing import Any, Dict, List import yaml @@ -45,8 +45,8 @@ # See the License for the specific language governing permissions and # limitations under the License.""" -SAMPLES_VERSIONS = ["2.7", "3.6", "3.7", "3.8"] -IGNORED_VERSIONS = ["2.7"] +SAMPLES_VERSIONS = ["3.6", "3.7", "3.8"] +IGNORED_VERSIONS: List[str] = [] SAMPLES_TEMPLATE_PATH = Path(CommonTemplates()._template_root) / "python_samples"