Skip to content

Commit facee4c

Browse files
tseaverparthea
andauthored
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 <[email protected]>
1 parent ff01716 commit facee4c

File tree

5 files changed

+9
-33
lines changed

5 files changed

+9
-33
lines changed

synthtool/gcp/common.py

-8
Original file line numberDiff line numberDiff line change
@@ -225,17 +225,9 @@ def py_library(self, **kwargs) -> Path:
225225
kwargs["default_python_version"] = "3.8"
226226
if "unit_test_python_versions" not in kwargs:
227227
kwargs["unit_test_python_versions"] = ["3.6", "3.7", "3.8", "3.9"]
228-
if "microgenerator" not in kwargs:
229-
kwargs["unit_test_python_versions"] = ["2.7"] + kwargs[
230-
"unit_test_python_versions"
231-
]
232228

233229
if "system_test_python_versions" not in kwargs:
234230
kwargs["system_test_python_versions"] = ["3.8"]
235-
if "microgenerator" not in kwargs:
236-
kwargs["system_test_python_versions"] = ["2.7"] + kwargs[
237-
"system_test_python_versions"
238-
]
239231

240232
# If cov_level is not given, set it to None.
241233
if "cov_level" not in kwargs:

synthtool/gcp/templates/python_library/noxfile.py.j2

+2-18
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ def default(session):
8787
constraints_path = str(
8888
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
8989
)
90-
{%- if microgenerator %}
91-
session.install("asyncmock", "pytest-asyncio", "-c", constraints_path)
92-
{% endif %}
93-
session.install("mock", "pytest", "pytest-cov", {% for d in unit_test_external_dependencies %}"{{d}}",{% endfor %} "-c", constraints_path)
90+
session.install("mock", "asyncmock", "pytest", "pytest-cov", "pytest-asyncio", "-c", constraints_path)
91+
{% for d in unit_test_external_dependencies %}session.install("{{d}}", "-c", constraints_path){% endfor %}
9492
{% for dependency in unit_test_local_dependencies %}session.install("-e", "{{dependency}}", "-c", constraints_path)
9593
{% endfor %}
9694
{% for dependency in unit_test_dependencies %}session.install("-e", "{{dependency}}", "-c", constraints_path){% endfor %}
@@ -192,20 +190,6 @@ def system(session):
192190
*session.posargs
193191
)
194192

195-
{% if samples_test %}
196-
@nox.session(python=["2.7", "3.7"])
197-
def samples(session):
198-
requirements_path = os.path.join("samples", "requirements.txt")
199-
requirements_exists = os.path.exists(requirements_path)
200-
201-
session.install("mock", "pytest")
202-
if requirements_exists:
203-
session.install("-r", requirements_path)
204-
session.install("-e", ".")
205-
206-
session.run("py.test", "--quiet", "samples", *session.posargs)
207-
{% endif %}
208-
209193
@nox.session(python=DEFAULT_PYTHON_VERSION)
210194
def cover(session):
211195
"""Run the final coverage report.

synthtool/gcp/templates/python_library/scripts/readme-gen/templates/install_deps.tmpl.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Install Dependencies
1212
.. _Python Development Environment Setup Guide:
1313
https://cloud.google.com/python/setup
1414

15-
#. Create a virtualenv. Samples are compatible with Python 2.7 and 3.4+.
15+
#. Create a virtualenv. Samples are compatible with Python 3.6+.
1616

1717
.. code-block:: bash
1818

synthtool/gcp/templates/python_samples/noxfile.py.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ BLACK_VERSION = "black==19.10b0"
3939

4040
TEST_CONFIG = {
4141
# You can opt out from the test for specific Python versions.
42-
'ignored_versions': ["2.7"],
42+
'ignored_versions': [],
4343

4444
# Old samples are opted out of enforcing Python type hints
4545
# All new samples should feature them
@@ -88,8 +88,8 @@ def get_pytest_env_vars() -> Dict[str, str]:
8888

8989

9090
# DO NOT EDIT - automatically generated.
91-
# All versions used to tested samples.
92-
ALL_VERSIONS = ["2.7", "3.6", "3.7", "3.8", "3.9"]
91+
# All versions used to test samples.
92+
ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
9393

9494
# Any default versions that should be ignored.
9595
IGNORED_VERSIONS = TEST_CONFIG['ignored_versions']

synthtool/languages/python.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import re
1616
import sys
1717
from pathlib import Path
18-
from typing import Any, Dict
18+
from typing import Any, Dict, List
1919

2020
import yaml
2121

@@ -45,8 +45,8 @@
4545
# See the License for the specific language governing permissions and
4646
# limitations under the License."""
4747

48-
SAMPLES_VERSIONS = ["2.7", "3.6", "3.7", "3.8"]
49-
IGNORED_VERSIONS = ["2.7"]
48+
SAMPLES_VERSIONS = ["3.6", "3.7", "3.8"]
49+
IGNORED_VERSIONS: List[str] = []
5050

5151
SAMPLES_TEMPLATE_PATH = Path(CommonTemplates()._template_root) / "python_samples"
5252

0 commit comments

Comments
 (0)