Skip to content

Commit

Permalink
Merge pull request #502 from mit-ll-responsible-ai/drop-37
Browse files Browse the repository at this point in the history
Drop support for python 3.7
  • Loading branch information
rsokl authored Jul 4, 2023
2 parents 3e087e3 + 1287bbc commit afed834
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 107 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tox_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10", 3.11]
python-version: [3.8, 3.9, "3.10", 3.11]
fail-fast: false

steps:
Expand Down Expand Up @@ -111,10 +111,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<img src="https://img.shields.io/pypi/v/hydra-zen.svg" alt="PyPI" />
</a>
<a>
<img src="https://img.shields.io/badge/python-3.7%20&#8208;%203.11-blue.svg" alt="Python version support" />
<img src="https://img.shields.io/badge/python-3.8%20&#8208;%203.11-blue.svg" alt="Python version support" />
</a>
<a href="https://github.com/mit-ll-responsible-ai/hydra-zen/actions?query=workflow%3ATests+branch%3Amain">
<img src="https://github.com/mit-ll-responsible-ai/hydra-zen/workflows/Tests/badge.svg" alt="GitHub Actions" />
Expand Down
8 changes: 5 additions & 3 deletions docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ chronological order. All previous releases should still be available on pip.

.. note:: This is documentation for an unreleased version of hydra-zen. You can try out this pre-release version using `pip install --pre hydra-zen`

This release drops support for hydra-core 1.1 and for omegaconf 2.1; this enabled the
removal of a lot of complex compatibility logic from hydra-zen's source code, and to
improve the behavior of :func:`~hydra_zen.zen`.
This release drops support for Python 3.7 (which reached its end of life), hydra-core
1.1 and for omegaconf 2.1; this enabled the removal of a lot of complex compatibility
logic from hydra-zen's source code, and to improve the behavior of
:func:`~hydra_zen.zen`.


Release Highlights
Expand Down Expand Up @@ -64,6 +65,7 @@ Compatibility-Breaking Changes
------------------------------
Most of these changes will not have any impact on users, based on download statistics and the particular code patterns impacted by the following changes.

- Python 3.8 is now the earliest supported version of Python supported by hydra-zen
- hydra-core 1.2.0 and omegaconf 2.2.1 are now the minimum supported versions of hydra-zen's dependencies.
- The auto-instantiation behavior of :class:`~hydra_zen.wrapper.Zen` and :func:`~hydra_zen.zen` have been updated so that nested dataclasses (nested within lists, dicts, and other dataclasses) will no longer be returned as omegaconf configs (see :pull:`448`).
- :func:`~hydra_zen.just` not longer returns a frozen dataclass (see :pull:`459`).
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ name = "hydra_zen"
dynamic = ["version"]
description = "Configurable, reproducible, and scalable workflows in Python, via Hydra"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
dependencies = ["hydra-core >= 1.2.0",
"omegaconf >= 2.2.1",
"typing-extensions >= 4.1.0, !=4.6.0",
Expand Down Expand Up @@ -127,11 +127,10 @@ skip = 'docs/build/*'
legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py37, py38, py39, py310, py311
envlist = py38, py39, py310, py311
[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
Expand All @@ -157,7 +156,7 @@ deps = hydra-core==1.2.0
omegaconf==2.2.1
typing-extensions==4.1.0
{[testenv]deps}
basepython = python3.7
basepython = python3.8
[testenv:pre-release]
Expand Down
8 changes: 0 additions & 8 deletions src/hydra_zen/_utils/coerce.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# Copyright (c) 2023 Massachusetts Institute of Technology
# SPDX-License-Identifier: MIT

import sys

if sys.version_info < (3, 7): # pragma: no cover
raise NotImplementedError(
"Features that utilize `hydra_zen._utils.coerce` "
"(e.g. beartype-validation) require Python 3.7 or greater."
)

import inspect
from collections import deque
from functools import wraps
Expand Down
2 changes: 1 addition & 1 deletion src/hydra_zen/structured_configs/_implementations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,7 @@ def builds(target, populate_full_signature=False, **kw):
): # pragma: no cover
# Exclude self/cls
#
# There are weird edge cases, like in collections.Counter for Python 3.7
# There are weird edge cases
# where the first arg is *args, not self.
_params = _params[1:]
else: # pragma: no cover
Expand Down
63 changes: 2 additions & 61 deletions src/hydra_zen/structured_configs/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
TypeVar,
Union,
cast,
get_args,
get_origin,
overload,
)

Expand Down Expand Up @@ -56,67 +58,6 @@
convert_types,
)

try:
from typing import get_args, get_origin
except ImportError: # pragma: no cover
# remove at Python 3.7 end-of-life
from collections.abc import Callable as _Callable

def get_origin(tp: Any) -> Union[None, type]:
"""Get the unsubscripted version of a type.
Parameters
----------
tp : Any
Returns
-------
Union[None, type]
Return None for unsupported types.
Notes
-----
Bare `Generic` not supported by this hacked version of `get_origin`
Examples
--------
>>> assert get_origin(Literal[42]) is Literal
>>> assert get_origin(int) is None
>>> assert get_origin(ClassVar[int]) is ClassVar
>>> assert get_origin(Generic[T]) is Generic
>>> assert get_origin(Union[T, int]) is Union
>>> assert get_origin(List[Tuple[T, T]][int]) == list
"""
return getattr(tp, "__origin__", None)

def get_args(tp: Any) -> Union[Tuple[type, ...], Tuple[List[type], type]]:
"""Get type arguments with all substitutions performed.
Parameters
----------
tp : Any
Returns
-------
Union[Tuple[type, ...], Tuple[List[type], type]]
Callable[[t1, ...], r] -> ([t1, ...], r)
Examples
--------
>>> assert get_args(Dict[str, int]) == (str, int)
>>> assert get_args(int) == ()
>>> assert get_args(Union[int, Union[T, int], str][int]) == (int, str)
>>> assert get_args(Union[int, Tuple[T, int]][str]) == (int, Tuple[str, int])
>>> assert get_args(Callable[[], T][int]) == ([], int)
"""
if hasattr(tp, "__origin__") and hasattr(tp, "__args__"):
args = tp.__args__
if get_origin(tp) is _Callable and args and args[0] is not Ellipsis:
args = (list(args[:-1]), args[-1])
return args
return ()


COMMON_MODULES_WITH_OBFUSCATED_IMPORTS: Tuple[str, ...] = (
"random",
"numpy",
Expand Down
17 changes: 0 additions & 17 deletions tests/test_py36.py

This file was deleted.

3 changes: 1 addition & 2 deletions tests/test_signature_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,7 @@ def test_parse_sig_with_new_vs_init(Obj):

def test_Counter():
# Counter has an interesting signature
# Python 3.7: (*args, **kwds) -- no self!
# >=3.8: (self, iterable=None, /, **kwds) -- pos-only
# Python >=3.8: (self, iterable=None, /, **kwds) -- pos-only
assert instantiate(builds(Counter, [1, 1, 2, 1])) == Counter([1, 1, 2, 1])
assert instantiate(builds(Counter, a=1, b=2)) == Counter(a=1, b=2)

Expand Down
11 changes: 4 additions & 7 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@ class SomeProtocol(Protocol[T]): # type: ignore

NoneType: TypeAlias = None

vList = List[Any] if sys.version_info < (3, 8) else List
vDict = Dict[Any, Any] if sys.version_info < (3, 8) else Dict


@pytest.mark.parametrize(
"in_type, expected_type",
Expand All @@ -158,14 +155,14 @@ class SomeProtocol(Protocol[T]): # type: ignore
(C, Any), # unsupported primitives
(type(None), Any),
(set, Any),
(list, (vList if OMEGACONF_VERSION < Version(2, 2, 3) else list)),
(list, (List if OMEGACONF_VERSION < Version(2, 2, 3) else list)),
(tuple, (Any if OMEGACONF_VERSION < Version(2, 2, 3) else tuple)),
(dict, (vDict if OMEGACONF_VERSION < Version(2, 2, 3) else dict)),
(dict, (Dict if OMEGACONF_VERSION < Version(2, 2, 3) else dict)),
(callable, Any),
(frozenset, Any),
(vList, vList),
(List, List),
(Tuple, (Any if OMEGACONF_VERSION < Version(2, 2, 3) else Tuple)),
(Dict, vDict),
(Dict, Dict),
(T, Any),
(List[T], List[Any]),
(Tuple[T, T], Tuple[Any, Any]),
Expand Down

0 comments on commit afed834

Please sign in to comment.