From 340a38fe9d7a5fa8b66f2597a6de88ae0d82790c Mon Sep 17 00:00:00 2001 From: Thomas M Kehrenberg Date: Sun, 18 Feb 2024 14:44:23 +0100 Subject: [PATCH 01/15] Preserve quote style when formatting --- poetry.lock | 39 +++++++++++++++++++-------------------- pyproject.toml | 3 ++- tests/misc_test.py | 4 ++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/poetry.lock b/poetry.lock index 46a5a796..0956c514 100644 --- a/poetry.lock +++ b/poetry.lock @@ -990,7 +990,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1048,28 +1047,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.2.1" +version = "0.2.2" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:dd81b911d28925e7e8b323e8d06951554655021df8dd4ac3045d7212ac4ba080"}, - {file = "ruff-0.2.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:dc586724a95b7d980aa17f671e173df00f0a2eef23f8babbeee663229a938fec"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c92db7101ef5bfc18e96777ed7bc7c822d545fa5977e90a585accac43d22f18a"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:13471684694d41ae0f1e8e3a7497e14cd57ccb7dd72ae08d56a159d6c9c3e30e"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a11567e20ea39d1f51aebd778685582d4c56ccb082c1161ffc10f79bebe6df35"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:00a818e2db63659570403e44383ab03c529c2b9678ba4ba6c105af7854008105"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be60592f9d218b52f03384d1325efa9d3b41e4c4d55ea022cd548547cc42cd2b"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:fbd2288890b88e8aab4499e55148805b58ec711053588cc2f0196a44f6e3d855"}, - {file = "ruff-0.2.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f3ef052283da7dec1987bba8d8733051c2325654641dfe5877a4022108098683"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:7022d66366d6fded4ba3889f73cd791c2d5621b2ccf34befc752cb0df70f5fad"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0a725823cb2a3f08ee743a534cb6935727d9e47409e4ad72c10a3faf042ad5ba"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0034d5b6323e6e8fe91b2a1e55b02d92d0b582d2953a2b37a67a2d7dedbb7acc"}, - {file = "ruff-0.2.1-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:e5cb5526d69bb9143c2e4d2a115d08ffca3d8e0fddc84925a7b54931c96f5c02"}, - {file = "ruff-0.2.1-py3-none-win32.whl", hash = "sha256:6b95ac9ce49b4fb390634d46d6ece32ace3acdd52814671ccaf20b7f60adb232"}, - {file = "ruff-0.2.1-py3-none-win_amd64.whl", hash = "sha256:e3affdcbc2afb6f5bd0eb3130139ceedc5e3f28d206fe49f63073cb9e65988e0"}, - {file = "ruff-0.2.1-py3-none-win_arm64.whl", hash = "sha256:efababa8e12330aa94a53e90a81eb6e2d55f348bc2e71adbf17d9cad23c03ee6"}, - {file = "ruff-0.2.1.tar.gz", hash = "sha256:3b42b5d8677cd0c72b99fcaf068ffc62abb5a19e71b4a3b9cfa50658a0af02f1"}, + {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0a9efb032855ffb3c21f6405751d5e147b0c6b631e3ca3f6b20f917572b97eb6"}, + {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:d450b7fbff85913f866a5384d8912710936e2b96da74541c82c1b458472ddb39"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ecd46e3106850a5c26aee114e562c329f9a1fbe9e4821b008c4404f64ff9ce73"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e22676a5b875bd72acd3d11d5fa9075d3a5f53b877fe7b4793e4673499318ba"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1695700d1e25a99d28f7a1636d85bafcc5030bba9d0578c0781ba1790dbcf51c"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b0c232af3d0bd8f521806223723456ffebf8e323bd1e4e82b0befb20ba18388e"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f63d96494eeec2fc70d909393bcd76c69f35334cdbd9e20d089fb3f0640216ca"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6a61ea0ff048e06de273b2e45bd72629f470f5da8f71daf09fe481278b175001"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e1439c8f407e4f356470e54cdecdca1bd5439a0673792dbe34a2b0a551a2fe3"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:940de32dc8853eba0f67f7198b3e79bc6ba95c2edbfdfac2144c8235114d6726"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c126da55c38dd917621552ab430213bdb3273bb10ddb67bc4b761989210eb6e"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3b65494f7e4bed2e74110dac1f0d17dc8e1f42faaa784e7c58a98e335ec83d7e"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1ec49be4fe6ddac0503833f3ed8930528e26d1e60ad35c2446da372d16651ce9"}, + {file = "ruff-0.2.2-py3-none-win32.whl", hash = "sha256:d920499b576f6c68295bc04e7b17b6544d9d05f196bb3aac4358792ef6f34325"}, + {file = "ruff-0.2.2-py3-none-win_amd64.whl", hash = "sha256:cc9a91ae137d687f43a44c900e5d95e9617cb37d4c989e462980ba27039d239d"}, + {file = "ruff-0.2.2-py3-none-win_arm64.whl", hash = "sha256:c9d15fc41e6054bfc7200478720570078f0b41c9ae4f010bcc16bd6f4d1aacdd"}, + {file = "ruff-0.2.2.tar.gz", hash = "sha256:e62ed7f36b3068a30ba39193a14274cd706bc486fad521276458022f7bccb31d"}, ] [[package]] @@ -1639,4 +1638,4 @@ wandb = ["pandas", "wandb"] [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.13" -content-hash = "2e62f5dab136f7836aaf8ca8f1203e2cf1e8d729e9a3cbfa3235bf4d3521dbd7" +content-hash = "b2f9811050666c2fd310398e92b9b293cfe34f096ac0bc7cd147cb2a3ad6ae22" diff --git a/pyproject.toml b/pyproject.toml index cfcb7889..176b962d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ hydra = ["attrs", "hydra-core", "neoconfigen"] all = ["attrs", "hydra-core", "loguru", "neoconfigen", "pandas", "wandb"] [tool.poetry.group.lint.dependencies] -ruff = ">=0.2" +ruff = ">=0.2.2" [tool.poetry.group.docs] optional = true @@ -97,6 +97,7 @@ line-length = 100 target-version = "py310" [tool.ruff.format] +quote-style = "preserve" exclude = [".undodir/*"] [tool.ruff.lint] diff --git a/tests/misc_test.py b/tests/misc_test.py index fbaef577..b24a9cfd 100644 --- a/tests/misc_test.py +++ b/tests/misc_test.py @@ -7,8 +7,8 @@ def test_flatten_dict() -> None: - d = {"a": 3, "b": {"c": 7.0, "d": {"e": True}, "f": -3}, "g": "hi"} - assert flatten_dict(d) == {"a": 3, "b.c": 7.0, "b.d.e": True, "b.f": -3, "g": "hi"} + d = {'a': 3, 'b': {'c': 7.0, 'd': {'e': True}, 'f': -3}, 'g': "hi"} + assert flatten_dict(d) == {'a': 3, 'b.c': 7.0, 'b.d.e': True, 'b.f': -3, 'g': "hi"} @dataclass From e80991dc7f7272cdcbc1fe02e3f5838d7e581322 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:17:40 +0000 Subject: [PATCH 02/15] Bump pre-commit from 3.6.1 to 3.6.2 Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.6.1 to 3.6.2. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v3.6.1...v3.6.2) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 0956c514..34c51059 100644 --- a/poetry.lock +++ b/poetry.lock @@ -821,13 +821,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pre-commit" -version = "3.6.1" +version = "3.6.2" description = "A framework for managing and maintaining multi-language pre-commit hooks." optional = false python-versions = ">=3.9" files = [ - {file = "pre_commit-3.6.1-py2.py3-none-any.whl", hash = "sha256:9fe989afcf095d2c4796ce7c553cf28d4d4a9b9346de3cda079bcf40748454a4"}, - {file = "pre_commit-3.6.1.tar.gz", hash = "sha256:c90961d8aa706f75d60935aba09469a6b0bcb8345f127c3fbee4bdc5f114cf4b"}, + {file = "pre_commit-3.6.2-py2.py3-none-any.whl", hash = "sha256:ba637c2d7a670c10daedc059f5c49b5bd0aadbccfcd7ec15592cf9665117532c"}, + {file = "pre_commit-3.6.2.tar.gz", hash = "sha256:c3ef34f463045c88658c5b99f38c1e297abdcc0ff13f98d3370055fbbfabc67e"}, ] [package.dependencies] @@ -990,6 +990,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, From 65cb71caa7df9e44c44f7b2c447607a30bbfa68b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:18:07 +0000 Subject: [PATCH 03/15] Bump pydoclint from 0.4.0 to 0.4.1 Bumps [pydoclint](https://github.com/jsh9/pydoclint) from 0.4.0 to 0.4.1. - [Release notes](https://github.com/jsh9/pydoclint/releases) - [Changelog](https://github.com/jsh9/pydoclint/blob/main/CHANGELOG.md) - [Commits](https://github.com/jsh9/pydoclint/compare/0.4.0...0.4.1) --- updated-dependencies: - dependency-name: pydoclint dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 0956c514..df11bf27 100644 --- a/poetry.lock +++ b/poetry.lock @@ -887,17 +887,17 @@ test = ["enum34", "ipaddress", "mock", "pywin32", "wmi"] [[package]] name = "pydoclint" -version = "0.4.0" +version = "0.4.1" description = "A Python docstring linter that checks arguments, returns, yields, and raises sections" optional = false python-versions = ">=3.8" files = [ - {file = "pydoclint-0.4.0-py2.py3-none-any.whl", hash = "sha256:2b266a1332f7c8a1badea115b164a230908004b349750c8ede553a96c4d991b4"}, - {file = "pydoclint-0.4.0.tar.gz", hash = "sha256:d645845e316463a151e0828013b4ea9cf4510626a6c4a5abbf7c0447ecafdd3b"}, + {file = "pydoclint-0.4.1-py2.py3-none-any.whl", hash = "sha256:4e32fdf0a47a2199377617f09af0a82a2157f80543026f919a17112a396e752f"}, + {file = "pydoclint-0.4.1.tar.gz", hash = "sha256:d39ed26a793203afadb1917011710fbf258ac3dddcd79b53212e0a2107221643"}, ] [package.dependencies] -click = ">=8.0.0" +click = ">=8.1.0" docstring-parser-fork = ">=0.0.5" tomli = {version = ">=2.0.1", markers = "python_version < \"3.11\""} @@ -990,6 +990,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, From 1ea95535891e3a4e6ede5b263ca3e8589f82acea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:18:25 +0000 Subject: [PATCH 04/15] Bump pandas-stubs from 2.1.4.231227 to 2.2.0.240218 Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 2.1.4.231227 to 2.2.0.240218. - [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md) - [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v2.1.4.231227...v2.2.0.240218) --- updated-dependencies: - dependency-name: pandas-stubs dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 0956c514..31ef3d14 100644 --- a/poetry.lock +++ b/poetry.lock @@ -776,13 +776,13 @@ test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] [[package]] name = "pandas-stubs" -version = "2.1.4.231227" +version = "2.2.0.240218" description = "Type annotations for pandas" optional = false python-versions = ">=3.9" files = [ - {file = "pandas_stubs-2.1.4.231227-py3-none-any.whl", hash = "sha256:211fc23e6ae87073bdf41dbf362c4a4d85e1e3477cb078dbac3da6c7fdaefba8"}, - {file = "pandas_stubs-2.1.4.231227.tar.gz", hash = "sha256:3ea29ef001e9e44985f5ebde02d4413f94891ef6ec7e5056fb07d125be796c23"}, + {file = "pandas_stubs-2.2.0.240218-py3-none-any.whl", hash = "sha256:e97478320add9b958391b15a56c5f1bf29da656d5b747d28bbe708454b3a1fe6"}, + {file = "pandas_stubs-2.2.0.240218.tar.gz", hash = "sha256:63138c12eec715d66d48611bdd922f31cd7c78bcadd19384c3bd61fd3720a11a"}, ] [package.dependencies] @@ -990,6 +990,7 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, + {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, From e01c005acc8681afe202cd82163164a3b4571609 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:49:16 +0000 Subject: [PATCH 05/15] Bump torch from 2.2.0+cpu to 2.2.1+cpu Bumps torch from 2.2.0+cpu to 2.2.1+cpu. --- updated-dependencies: - dependency-name: torch dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/poetry.lock b/poetry.lock index 99718003..89cfc46e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1470,21 +1470,21 @@ files = [ [[package]] name = "torch" -version = "2.2.0+cpu" +version = "2.2.1+cpu" description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" optional = false python-versions = ">=3.8.0" files = [ - {file = "torch-2.2.0+cpu-cp310-cp310-linux_x86_64.whl", hash = "sha256:5f907293f5a58619c1c520380f17641f76400a136474a4b1a66c363d2563fe5e"}, - {file = "torch-2.2.0+cpu-cp310-cp310-win_amd64.whl", hash = "sha256:15a657038eea92ac5db6ab97b30bd4b5345741b49553b2a7e552e80001297124"}, - {file = "torch-2.2.0+cpu-cp311-cp311-linux_x86_64.whl", hash = "sha256:2a8ff4440c1f024ad7982018c378470d2ae0a72f2bc269a22b1a677e09bdd3b1"}, - {file = "torch-2.2.0+cpu-cp311-cp311-win_amd64.whl", hash = "sha256:58194066e594cd8aff27ddb746399d040900cc0e8a331d67ea98499777fa4d31"}, - {file = "torch-2.2.0+cpu-cp312-cp312-linux_x86_64.whl", hash = "sha256:8258824bec0181e01a086aef5809016116a97626af2dcbf932d4e0b192d9c1b8"}, - {file = "torch-2.2.0+cpu-cp312-cp312-win_amd64.whl", hash = "sha256:5b40dc66914c02d564365f991ec9a6b18cbaa586610e3b160ef559b2ce18c6c8"}, - {file = "torch-2.2.0+cpu-cp38-cp38-linux_x86_64.whl", hash = "sha256:f72e7ce8010aa8797665ff6c4c1d259c28f3a51f332762d9de77f8a20277817f"}, - {file = "torch-2.2.0+cpu-cp38-cp38-win_amd64.whl", hash = "sha256:15e05748815545b6eb99196c0219822b210a5eff0dc194997a283534b8c98d7c"}, - {file = "torch-2.2.0+cpu-cp39-cp39-linux_x86_64.whl", hash = "sha256:4ddaf3393f5123da4a83a53f98fb9c9c64c53d0061da3c7243f982cdfe9eb888"}, - {file = "torch-2.2.0+cpu-cp39-cp39-win_amd64.whl", hash = "sha256:d053976a4f9ca3bace6e4191e0b6e0bcffbc29f70d419b14d01228b371335467"}, + {file = "torch-2.2.1+cpu-cp310-cp310-linux_x86_64.whl", hash = "sha256:5d82422cf04797f1b2a8574b64a916070ec83eef58ad4900615ee0218d7b8b8e"}, + {file = "torch-2.2.1+cpu-cp310-cp310-win_amd64.whl", hash = "sha256:f8914dd0f5f0e5c66fdecd9559403eea9feac82d1ea639b672fde0073c6addbd"}, + {file = "torch-2.2.1+cpu-cp311-cp311-linux_x86_64.whl", hash = "sha256:6bc973d5632374b92b4b293817b4d2ff8c8ce1c784c748b471dba1fffcd9c333"}, + {file = "torch-2.2.1+cpu-cp311-cp311-win_amd64.whl", hash = "sha256:abdec34b0ade8fca0520055e72c3094425ae0ef210718e9c0278121cd3608c32"}, + {file = "torch-2.2.1+cpu-cp312-cp312-linux_x86_64.whl", hash = "sha256:d7339580135da4105c1244a8621faa076990409afeab5a7b642c3c1ee70a5622"}, + {file = "torch-2.2.1+cpu-cp312-cp312-win_amd64.whl", hash = "sha256:039128fcb5548122465b15f679b8831c47d14f0d6c28c1f1b631f8019c104720"}, + {file = "torch-2.2.1+cpu-cp38-cp38-linux_x86_64.whl", hash = "sha256:2b447f7bb50b393b4544b4036d587e39ab524d4353e77c197f6a2727f22b0d47"}, + {file = "torch-2.2.1+cpu-cp38-cp38-win_amd64.whl", hash = "sha256:2ccdf3e5f71e6426ea9e34d21c3cc333b29d4f48299b981d28aeb5112b5495e1"}, + {file = "torch-2.2.1+cpu-cp39-cp39-linux_x86_64.whl", hash = "sha256:2fb340b289760040a16a77a6d70b8a48961abba1822e6f58705c97c80befa03e"}, + {file = "torch-2.2.1+cpu-cp39-cp39-win_amd64.whl", hash = "sha256:e03dc4654ecceeb5b03f0a6f60b342c0e0d267b3ebc61e4f672cace1df8cd930"}, ] [package.dependencies] From cf29a8d51be3eb6d1b52f6143e70125cceb0b938 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 06:49:42 +0000 Subject: [PATCH 06/15] Bump typing-extensions from 4.9.0 to 4.10.0 Bumps [typing-extensions](https://github.com/python/typing_extensions) from 4.9.0 to 4.10.0. - [Release notes](https://github.com/python/typing_extensions/releases) - [Changelog](https://github.com/python/typing_extensions/blob/main/CHANGELOG.md) - [Commits](https://github.com/python/typing_extensions/commits) --- updated-dependencies: - dependency-name: typing-extensions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 99718003..10215cf4 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1517,13 +1517,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.9.0" +version = "4.10.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, + {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, + {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, ] [[package]] From 2cb1f410e34df906551d8030a85de1c6b51d9e92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 06:28:10 +0000 Subject: [PATCH 07/15] Bump ruff from 0.2.2 to 0.3.0 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.2.2 to 0.3.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.2.2...v0.3.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index 5deb8a3e..d99b00b8 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1048,28 +1048,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.2.2" +version = "0.3.0" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0a9efb032855ffb3c21f6405751d5e147b0c6b631e3ca3f6b20f917572b97eb6"}, - {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:d450b7fbff85913f866a5384d8912710936e2b96da74541c82c1b458472ddb39"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ecd46e3106850a5c26aee114e562c329f9a1fbe9e4821b008c4404f64ff9ce73"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e22676a5b875bd72acd3d11d5fa9075d3a5f53b877fe7b4793e4673499318ba"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1695700d1e25a99d28f7a1636d85bafcc5030bba9d0578c0781ba1790dbcf51c"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b0c232af3d0bd8f521806223723456ffebf8e323bd1e4e82b0befb20ba18388e"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f63d96494eeec2fc70d909393bcd76c69f35334cdbd9e20d089fb3f0640216ca"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6a61ea0ff048e06de273b2e45bd72629f470f5da8f71daf09fe481278b175001"}, - {file = "ruff-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e1439c8f407e4f356470e54cdecdca1bd5439a0673792dbe34a2b0a551a2fe3"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:940de32dc8853eba0f67f7198b3e79bc6ba95c2edbfdfac2144c8235114d6726"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c126da55c38dd917621552ab430213bdb3273bb10ddb67bc4b761989210eb6e"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3b65494f7e4bed2e74110dac1f0d17dc8e1f42faaa784e7c58a98e335ec83d7e"}, - {file = "ruff-0.2.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1ec49be4fe6ddac0503833f3ed8930528e26d1e60ad35c2446da372d16651ce9"}, - {file = "ruff-0.2.2-py3-none-win32.whl", hash = "sha256:d920499b576f6c68295bc04e7b17b6544d9d05f196bb3aac4358792ef6f34325"}, - {file = "ruff-0.2.2-py3-none-win_amd64.whl", hash = "sha256:cc9a91ae137d687f43a44c900e5d95e9617cb37d4c989e462980ba27039d239d"}, - {file = "ruff-0.2.2-py3-none-win_arm64.whl", hash = "sha256:c9d15fc41e6054bfc7200478720570078f0b41c9ae4f010bcc16bd6f4d1aacdd"}, - {file = "ruff-0.2.2.tar.gz", hash = "sha256:e62ed7f36b3068a30ba39193a14274cd706bc486fad521276458022f7bccb31d"}, + {file = "ruff-0.3.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:7deb528029bacf845bdbb3dbb2927d8ef9b4356a5e731b10eef171e3f0a85944"}, + {file = "ruff-0.3.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e1e0d4381ca88fb2b73ea0766008e703f33f460295de658f5467f6f229658c19"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2f7dbba46e2827dfcb0f0cc55fba8e96ba7c8700e0a866eb8cef7d1d66c25dcb"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:23dbb808e2f1d68eeadd5f655485e235c102ac6f12ad31505804edced2a5ae77"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ef655c51f41d5fa879f98e40c90072b567c666a7114fa2d9fe004dffba00932"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d0d3d7ef3d4f06433d592e5f7d813314a34601e6c5be8481cccb7fa760aa243e"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b08b356d06a792e49a12074b62222f9d4ea2a11dca9da9f68163b28c71bf1dd4"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9343690f95710f8cf251bee1013bf43030072b9f8d012fbed6ad702ef70d360a"}, + {file = "ruff-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1f3ed501a42f60f4dedb7805fa8d4534e78b4e196f536bac926f805f0743d49"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:cc30a9053ff2f1ffb505a585797c23434d5f6c838bacfe206c0e6cf38c921a1e"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5da894a29ec018a8293d3d17c797e73b374773943e8369cfc50495573d396933"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:755c22536d7f1889be25f2baf6fedd019d0c51d079e8417d4441159f3bcd30c2"}, + {file = "ruff-0.3.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:dd73fe7f4c28d317855da6a7bc4aa29a1500320818dd8f27df95f70a01b8171f"}, + {file = "ruff-0.3.0-py3-none-win32.whl", hash = "sha256:19eacceb4c9406f6c41af806418a26fdb23120dfe53583df76d1401c92b7c14b"}, + {file = "ruff-0.3.0-py3-none-win_amd64.whl", hash = "sha256:128265876c1d703e5f5e5a4543bd8be47c73a9ba223fd3989d4aa87dd06f312f"}, + {file = "ruff-0.3.0-py3-none-win_arm64.whl", hash = "sha256:e3a4a6d46aef0a84b74fcd201a4401ea9a6cd85614f6a9435f2d33dd8cefbf83"}, + {file = "ruff-0.3.0.tar.gz", hash = "sha256:0886184ba2618d815067cf43e005388967b67ab9c80df52b32ec1152ab49f53a"}, ] [[package]] From 19b11372c86d30c134c03749ca271dd34fb813b3 Mon Sep 17 00:00:00 2001 From: Thomas M Kehrenberg Date: Mon, 4 Mar 2024 13:57:00 +0100 Subject: [PATCH 08/15] Format code with new style --- pyproject.toml | 55 ++++++++++++++----------------- ranzen/decorators.py | 4 +-- ranzen/hydra/utils.py | 1 + ranzen/misc.py | 30 ++++++----------- ranzen/torch/data.py | 3 +- ranzen/torch/schedulers.py | 51 ++++++++++------------------ ranzen/torch/transforms/cutmix.py | 12 +++---- ranzen/torch/transforms/mixup.py | 12 +++---- ranzen/torch/utils.py | 6 ++-- ranzen/types.py | 12 +++---- ranzen/wandb.py | 1 + tests/decorator_test.py | 7 ++-- tests/relay_test.py | 3 +- 13 files changed, 75 insertions(+), 122 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 176b962d..41f7d9b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,11 +4,9 @@ version = "3.0.0.dev0" description = "A toolkit facilitating machine-learning experimentation." authors = ["PAL "] license = "Apache License 2.0" -packages = [ - { include = "ranzen" }, -] -include=["ranzen/py.typed"] -classifiers=[ +packages = [{ include = "ranzen" }] +include = ["ranzen/py.typed"] +classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", @@ -16,9 +14,9 @@ classifiers=[ "Operating System :: OS Independent", "Typing :: Typed", ] -keywords=["typing", "python"] -repository="https://github.com/wearepal/ranzen" -readme="README.md" +keywords = ["typing", "python"] +repository = "https://github.com/wearepal/ranzen" +readme = "README.md" [tool.poetry.dependencies] python = ">=3.10,<3.13" @@ -27,7 +25,7 @@ numpy = "^1.23.2" # wandb dependencies pandas = { version = "^1.5.0", optional = true } -wandb = { version= ">=0.15", optional = true } +wandb = { version = ">=0.15", optional = true } # logging dependencies loguru = { version = "^0.6.0", optional = true } @@ -102,25 +100,25 @@ exclude = [".undodir/*"] [tool.ruff.lint] select = [ - "E", # pycodestyle - "F", # pyflakes - "FBT", # boolean trap - "I", # isort - # "N", # naming - "PLC", # pylint convention - "PLE", # pylint error - # "PLR", # pylint refactor - "PLW", # pylint warning - "PTH", # use-pathlib - # "UP", # pyupgrade - "UP035", # newer imports - "W", + "E", # pycodestyle + "F", # pyflakes + "FBT", # boolean trap + "I", # isort + # "N", # naming + "PLC", # pylint convention + "PLE", # pylint error + # "PLR", # pylint refactor + "PLW", # pylint warning + "PTH", # use-pathlib + # "UP", # pyupgrade + "UP035", # newer imports + "W", ] ignore = [ - "E501", # line length - "F541", # f-string without placeholder - "PLW2901", # overwriting loop variable - "PLC0105", # covariant typevars have to end in "_co" + "E501", # line length + "F541", # f-string without placeholder + "PLW2901", # overwriting loop variable + "PLC0105", # covariant typevars have to end in "_co" ] [tool.ruff.lint.per-file-ignores] @@ -149,10 +147,7 @@ extra-standard-library = ["typing_extensions"] no-lines-before = ["future", "standard-library"] force-sort-within-sections = true split-on-trailing-comma = false -classes = [ - "SAM", - "LAMB", -] +classes = ["SAM", "LAMB"] [tool.pydoclint] style = "sphinx" diff --git a/ranzen/decorators.py b/ranzen/decorators.py index e4803708..50dd6abd 100644 --- a/ranzen/decorators.py +++ b/ranzen/decorators.py @@ -1,4 +1,5 @@ """Decorator functions.""" + from collections.abc import Callable from enum import Enum from typing import Any, Protocol, TypeVar @@ -12,8 +13,7 @@ class IdentityFunction(Protocol[_T]): - def __call__(self, __x: _T) -> _T: - ... + def __call__(self, __x: _T) -> _T: ... @deprecated("Use 'typing_extensions.override' instead.") diff --git a/ranzen/hydra/utils.py b/ranzen/hydra/utils.py index 6adb6b16..ea0d0cf6 100644 --- a/ranzen/hydra/utils.py +++ b/ranzen/hydra/utils.py @@ -1,4 +1,5 @@ """Functions for dealing with hydra.""" + from collections.abc import Iterator, MutableMapping, Sequence from contextlib import contextmanager import dataclasses diff --git a/ranzen/misc.py b/ranzen/misc.py index b77e152a..25b0dd51 100644 --- a/ranzen/misc.py +++ b/ranzen/misc.py @@ -54,13 +54,11 @@ def flatten_dict(d: Mapping[str, Any], *, parent_key: str = "", sep: str = ".") @overload -def gcopy(obj: T, *, deep: bool = True, num_copies: None = ..., **kwargs: Any) -> T: - ... +def gcopy(obj: T, *, deep: bool = True, num_copies: None = ..., **kwargs: Any) -> T: ... @overload -def gcopy(obj: T, *, deep: bool = True, num_copies: int, **kwargs: Any) -> list[T]: - ... +def gcopy(obj: T, *, deep: bool = True, num_copies: int, **kwargs: Any) -> list[T]: ... def gcopy( @@ -204,12 +202,10 @@ class AddDict(dict[_KT, _VT], Addable[int | dict, dict]): """ @overload - def __add__(self, other: int) -> Self: - ... + def __add__(self, other: int) -> Self: ... @overload - def __add__(self, other: dict[_KT, _VT2]) -> AddDict[_KT, _VT | _VT2]: - ... + def __add__(self, other: dict[_KT, _VT2]) -> AddDict[_KT, _VT | _VT2]: ... def __add__(self, other: int | dict[_KT, _VT2]) -> Self | AddDict[_KT, _VT | _VT2]: # Allow ``other`` to be an integer, but specifying the identity function, for compatibility @@ -240,12 +236,10 @@ def __add__(self, other: int | dict[_KT, _VT2]) -> Self | AddDict[_KT, _VT | _VT return copy @overload - def __radd__(self, other: int) -> Self: - ... + def __radd__(self, other: int) -> Self: ... @overload - def __radd__(self, other: dict[_KT, _VT2]) -> AddDict[_KT, _VT | _VT2]: - ... + def __radd__(self, other: dict[_KT, _VT2]) -> AddDict[_KT, _VT | _VT2]: ... def __radd__(self, other: int | dict[_KT, _VT2]) -> Self | AddDict[_KT, _VT | _VT2]: # Calling `__add__` directly because with the `+` syntax, pyright complains for some reason. @@ -316,8 +310,7 @@ def prop_random_split( as_indices: Literal[False] = ..., seed: int | None = ..., reproducible: bool = ..., -) -> list[Subset[D]]: - ... +) -> list[Subset[D]]: ... @overload @@ -328,8 +321,7 @@ def prop_random_split( as_indices: Literal[True], seed: int | None = ..., reproducible: bool = ..., -) -> list[list[int]]: - ... +) -> list[list[int]]: ... @overload @@ -340,8 +332,7 @@ def prop_random_split( as_indices: bool = ..., seed: int | None = ..., reproducible: bool = ..., -) -> list[list[int]]: - ... +) -> list[list[int]]: ... @overload @@ -352,8 +343,7 @@ def prop_random_split( as_indices: bool = ..., seed: int | None = ..., reproducible: bool = ..., -) -> list[Subset[D]] | list[list[int]]: - ... +) -> list[Subset[D]] | list[list[int]]: ... def prop_random_split( diff --git a/ranzen/torch/data.py b/ranzen/torch/data.py index e4444223..f3cc2323 100644 --- a/ranzen/torch/data.py +++ b/ranzen/torch/data.py @@ -120,8 +120,7 @@ def __init__(self, epoch_length: int | None = None) -> None: @override @abstractmethod - def __iter__(self) -> Iterator[list[int]]: - ... + def __iter__(self) -> Iterator[list[int]]: ... def __len__(self) -> float | int: """The number of samples drawn. diff --git a/ranzen/torch/schedulers.py b/ranzen/torch/schedulers.py index 59f98ca6..7fc81621 100644 --- a/ranzen/torch/schedulers.py +++ b/ranzen/torch/schedulers.py @@ -162,8 +162,7 @@ def __post_init__(self) -> None: self.val = self.start_val @abstractmethod - def _update(self, value: T) -> T: - ... + def _update(self, value: T) -> T: ... @torch.no_grad() # pyright: ignore def step(self) -> None: @@ -171,77 +170,61 @@ def step(self) -> None: self.val = self._update(self.val) @overload - def __add__(self: "Scheduler[Tensor]", other: float) -> Tensor: - ... + def __add__(self: "Scheduler[Tensor]", other: float) -> Tensor: ... @overload - def __add__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: - ... + def __add__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: ... @overload - def __add__(self: "Scheduler[float]", other: float) -> float: - ... + def __add__(self: "Scheduler[float]", other: float) -> float: ... @overload - def __add__(self: "Scheduler[float]", other: Tensor) -> Tensor: - ... + def __add__(self: "Scheduler[float]", other: Tensor) -> Tensor: ... def __add__(self, other: Union[Tensor, float]) -> Union[Tensor, float]: return other + self.val @overload - def __mul__(self: "Scheduler[Tensor]", other: float) -> Tensor: - ... + def __mul__(self: "Scheduler[Tensor]", other: float) -> Tensor: ... @overload - def __mul__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: - ... + def __mul__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: ... @overload - def __mul__(self: "Scheduler[float]", other: float) -> float: - ... + def __mul__(self: "Scheduler[float]", other: float) -> float: ... @overload - def __mul__(self: "Scheduler[float]", other: Tensor) -> Tensor: - ... + def __mul__(self: "Scheduler[float]", other: Tensor) -> Tensor: ... def __mul__(self, other: Union[Tensor, float]) -> Union[Tensor, float]: return other * self.val @overload - def __imul__(self: "Scheduler[Tensor]", other: float) -> Tensor: - ... + def __imul__(self: "Scheduler[Tensor]", other: float) -> Tensor: ... @overload - def __imul__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: - ... + def __imul__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: ... @overload - def __imul__(self: "Scheduler[float]", other: float) -> float: - ... + def __imul__(self: "Scheduler[float]", other: float) -> float: ... @overload - def __imul__(self: "Scheduler[float]", other: Tensor) -> Tensor: - ... + def __imul__(self: "Scheduler[float]", other: Tensor) -> Tensor: ... def __imul__(self, other: Union[Tensor, float]) -> Union[Tensor, float]: return other * self.val @overload - def __rmul__(self: "Scheduler[Tensor]", other: float) -> Tensor: - ... + def __rmul__(self: "Scheduler[Tensor]", other: float) -> Tensor: ... @overload - def __rmul__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: - ... + def __rmul__(self: "Scheduler[Tensor]", other: Tensor) -> Tensor: ... @overload - def __rmul__(self: "Scheduler[float]", other: float) -> float: - ... + def __rmul__(self: "Scheduler[float]", other: float) -> float: ... @overload - def __rmul__(self: "Scheduler[float]", other: Tensor) -> Tensor: - ... + def __rmul__(self: "Scheduler[float]", other: Tensor) -> Tensor: ... def __rmul__(self, other: Union[Tensor, float]) -> Union[Tensor, float]: return other * self.val diff --git a/ranzen/torch/transforms/cutmix.py b/ranzen/torch/transforms/cutmix.py index 503f8be7..ab6dba82 100644 --- a/ranzen/torch/transforms/cutmix.py +++ b/ranzen/torch/transforms/cutmix.py @@ -113,8 +113,7 @@ def _transform( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = None, - ) -> InputsTargetsPair: - ... + ) -> InputsTargetsPair: ... @overload def _transform( @@ -125,8 +124,7 @@ def _transform( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = None, - ) -> Tensor: - ... + ) -> Tensor: ... def _transform( self, @@ -198,8 +196,7 @@ def __call__( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = ..., - ) -> InputsTargetsPair: - ... + ) -> InputsTargetsPair: ... @overload def __call__( @@ -210,8 +207,7 @@ def __call__( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = ..., - ) -> Tensor: - ... + ) -> Tensor: ... def __call__( self, diff --git a/ranzen/torch/transforms/mixup.py b/ranzen/torch/transforms/mixup.py index dbfc20c8..96967a36 100644 --- a/ranzen/torch/transforms/mixup.py +++ b/ranzen/torch/transforms/mixup.py @@ -262,8 +262,7 @@ def _transform( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = ..., - ) -> InputsTargetsPair: - ... + ) -> InputsTargetsPair: ... @overload def _transform( @@ -274,8 +273,7 @@ def _transform( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = ..., - ) -> Tensor: - ... + ) -> Tensor: ... def _transform( self, @@ -358,8 +356,7 @@ def __call__( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = ..., - ) -> InputsTargetsPair: - ... + ) -> InputsTargetsPair: ... @overload def __call__( @@ -370,8 +367,7 @@ def __call__( groups_or_edges: Tensor | None = ..., cross_group: bool = ..., num_classes: int | None = ..., - ) -> Tensor: - ... + ) -> Tensor: ... def __call__( self, diff --git a/ranzen/torch/utils.py b/ranzen/torch/utils.py index 64b870bf..68ee4c0b 100644 --- a/ranzen/torch/utils.py +++ b/ranzen/torch/utils.py @@ -148,13 +148,11 @@ def batchwise_pdist(x: Tensor, chunk_size: int = 1000, p_norm: float = 2.0) -> T @overload -def to_numpy(tensor: Tensor, *, dtype: DT) -> npt.NDArray[DT]: - ... +def to_numpy(tensor: Tensor, *, dtype: DT) -> npt.NDArray[DT]: ... @overload -def to_numpy(tensor: Tensor, *, dtype: None = ...) -> npt.NDArray: - ... +def to_numpy(tensor: Tensor, *, dtype: None = ...) -> npt.NDArray: ... def to_numpy( diff --git a/ranzen/types.py b/ranzen/types.py index a5b862e6..7f3849e9 100644 --- a/ranzen/types.py +++ b/ranzen/types.py @@ -20,14 +20,12 @@ @runtime_checkable class Sized(Protocol[T_co]): - def __len__(self) -> int: - ... + def __len__(self) -> int: ... @runtime_checkable class Addable(Protocol[T_contra, T_co]): - def __add__(self, other: T_contra, /) -> T_co: - ... + def __add__(self, other: T_contra, /) -> T_co: ... @runtime_checkable @@ -71,11 +69,9 @@ def is_td_instance(dict_: dict[str, Any], cls_: type[TD], *, strict: bool = Fals @runtime_checkable class SizedDataset(Protocol[T_co]): - def __getitem__(self, index: int) -> T_co: - ... + def __getitem__(self, index: int) -> T_co: ... - def __len__(self) -> int: - ... + def __len__(self) -> int: ... D = TypeVar("D", bound=SizedDataset) diff --git a/ranzen/wandb.py b/ranzen/wandb.py index 03241e5d..1de6ce90 100644 --- a/ranzen/wandb.py +++ b/ranzen/wandb.py @@ -1,4 +1,5 @@ """Wandb-related functionality.""" + from collections.abc import Sequence from functools import lru_cache diff --git a/tests/decorator_test.py b/tests/decorator_test.py index fa743529..562dcca8 100644 --- a/tests/decorator_test.py +++ b/tests/decorator_test.py @@ -1,4 +1,5 @@ """Test decorators.""" + from enum import Enum, auto from typing_extensions import deprecated @@ -11,15 +12,13 @@ def test_deprecated(explanation: str) -> None: @deprecated(explanation) class Foo: - def __init__(self) -> None: - ... + def __init__(self) -> None: ... with pytest.deprecated_call(): Foo() # pyright: ignore @deprecated(explanation) - def foo() -> None: - ... + def foo() -> None: ... with pytest.deprecated_call(): foo() # pyright: ignore diff --git a/tests/relay_test.py b/tests/relay_test.py index 8ae3722f..689af819 100644 --- a/tests/relay_test.py +++ b/tests/relay_test.py @@ -14,8 +14,7 @@ class DummyOption(Protocol): name: str @property - def value(self) -> int | str: - ... + def value(self) -> int | str: ... @dataclass From bc0e516616a2e49e0d6c303b1d982edfb14e4712 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 06:13:52 +0000 Subject: [PATCH 09/15] Bump wandb from 0.16.3 to 0.16.4 Bumps [wandb](https://github.com/wandb/wandb) from 0.16.3 to 0.16.4. - [Release notes](https://github.com/wandb/wandb/releases) - [Changelog](https://github.com/wandb/wandb/blob/main/CHANGELOG.md) - [Commits](https://github.com/wandb/wandb/compare/v0.16.3...v0.16.4) --- updated-dependencies: - dependency-name: wandb dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index d99b00b8..1abb2176 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1581,13 +1581,13 @@ test = ["covdefaults (>=2.3)", "coverage (>=7.2.7)", "coverage-enable-subprocess [[package]] name = "wandb" -version = "0.16.3" +version = "0.16.4" description = "A CLI and library for interacting with the Weights & Biases API." optional = true python-versions = ">=3.7" files = [ - {file = "wandb-0.16.3-py3-none-any.whl", hash = "sha256:b8907ddd775c27dc6c12687386a86b5d6acf291060f9ae680bbc61cc8fc03237"}, - {file = "wandb-0.16.3.tar.gz", hash = "sha256:d789acda32053b18b7a160d0595837e45a3c8a79d25e1fe1f051875303f480ec"}, + {file = "wandb-0.16.4-py3-none-any.whl", hash = "sha256:bb9eb5aa2c2c85e11c76040c4271366f54d4975167aa6320ba86c3f2d97fe5fa"}, + {file = "wandb-0.16.4.tar.gz", hash = "sha256:8752c67d1347a4c29777e64dc1e1a742a66c5ecde03aebadf2b0d62183fa307c"}, ] [package.dependencies] @@ -1608,8 +1608,9 @@ async = ["httpx (>=0.23.0)"] aws = ["boto3"] azure = ["azure-identity", "azure-storage-blob"] gcp = ["google-cloud-storage"] +importers = ["filelock", "mlflow", "polars", "rich", "tenacity"] kubeflow = ["google-cloud-storage", "kubernetes", "minio", "sh"] -launch = ["PyYAML (>=6.0.0)", "awscli", "azure-containerregistry", "azure-identity", "azure-storage-blob", "boto3", "botocore", "chardet", "google-auth", "google-cloud-aiplatform", "google-cloud-artifact-registry", "google-cloud-compute", "google-cloud-storage", "iso8601", "kubernetes", "kubernetes-asyncio", "nbconvert", "nbformat", "optuna", "pydantic", "typing-extensions"] +launch = ["PyYAML (>=6.0.0)", "awscli", "azure-containerregistry", "azure-identity", "azure-storage-blob", "boto3", "botocore", "chardet", "google-auth", "google-cloud-aiplatform", "google-cloud-artifact-registry", "google-cloud-compute", "google-cloud-storage", "iso8601", "kubernetes", "kubernetes-asyncio", "nbconvert", "nbformat", "optuna", "pydantic", "tomli", "typing-extensions"] media = ["bokeh", "moviepy", "numpy", "pillow", "plotly (>=5.18.0)", "rdkit-pypi", "soundfile"] models = ["cloudpickle"] perf = ["orjson"] From 35ed6bb3639cbad8501db8cbf62969fcad47335f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 06:14:37 +0000 Subject: [PATCH 10/15] Bump ruff from 0.3.0 to 0.3.2 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.0 to 0.3.2. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.0...v0.3.2) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index d99b00b8..aab9b984 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1048,28 +1048,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.3.0" +version = "0.3.2" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.3.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:7deb528029bacf845bdbb3dbb2927d8ef9b4356a5e731b10eef171e3f0a85944"}, - {file = "ruff-0.3.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e1e0d4381ca88fb2b73ea0766008e703f33f460295de658f5467f6f229658c19"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2f7dbba46e2827dfcb0f0cc55fba8e96ba7c8700e0a866eb8cef7d1d66c25dcb"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:23dbb808e2f1d68eeadd5f655485e235c102ac6f12ad31505804edced2a5ae77"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ef655c51f41d5fa879f98e40c90072b567c666a7114fa2d9fe004dffba00932"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:d0d3d7ef3d4f06433d592e5f7d813314a34601e6c5be8481cccb7fa760aa243e"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b08b356d06a792e49a12074b62222f9d4ea2a11dca9da9f68163b28c71bf1dd4"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9343690f95710f8cf251bee1013bf43030072b9f8d012fbed6ad702ef70d360a"}, - {file = "ruff-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a1f3ed501a42f60f4dedb7805fa8d4534e78b4e196f536bac926f805f0743d49"}, - {file = "ruff-0.3.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:cc30a9053ff2f1ffb505a585797c23434d5f6c838bacfe206c0e6cf38c921a1e"}, - {file = "ruff-0.3.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5da894a29ec018a8293d3d17c797e73b374773943e8369cfc50495573d396933"}, - {file = "ruff-0.3.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:755c22536d7f1889be25f2baf6fedd019d0c51d079e8417d4441159f3bcd30c2"}, - {file = "ruff-0.3.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:dd73fe7f4c28d317855da6a7bc4aa29a1500320818dd8f27df95f70a01b8171f"}, - {file = "ruff-0.3.0-py3-none-win32.whl", hash = "sha256:19eacceb4c9406f6c41af806418a26fdb23120dfe53583df76d1401c92b7c14b"}, - {file = "ruff-0.3.0-py3-none-win_amd64.whl", hash = "sha256:128265876c1d703e5f5e5a4543bd8be47c73a9ba223fd3989d4aa87dd06f312f"}, - {file = "ruff-0.3.0-py3-none-win_arm64.whl", hash = "sha256:e3a4a6d46aef0a84b74fcd201a4401ea9a6cd85614f6a9435f2d33dd8cefbf83"}, - {file = "ruff-0.3.0.tar.gz", hash = "sha256:0886184ba2618d815067cf43e005388967b67ab9c80df52b32ec1152ab49f53a"}, + {file = "ruff-0.3.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:77f2612752e25f730da7421ca5e3147b213dca4f9a0f7e0b534e9562c5441f01"}, + {file = "ruff-0.3.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9966b964b2dd1107797be9ca7195002b874424d1d5472097701ae8f43eadef5d"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b83d17ff166aa0659d1e1deaf9f2f14cbe387293a906de09bc4860717eb2e2da"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bb875c6cc87b3703aeda85f01c9aebdce3d217aeaca3c2e52e38077383f7268a"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be75e468a6a86426430373d81c041b7605137a28f7014a72d2fc749e47f572aa"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:967978ac2d4506255e2f52afe70dda023fc602b283e97685c8447d036863a302"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1231eacd4510f73222940727ac927bc5d07667a86b0cbe822024dd00343e77e9"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2c6d613b19e9a8021be2ee1d0e27710208d1603b56f47203d0abbde906929a9b"}, + {file = "ruff-0.3.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c8439338a6303585d27b66b4626cbde89bb3e50fa3cae86ce52c1db7449330a7"}, + {file = "ruff-0.3.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:de8b480d8379620cbb5ea466a9e53bb467d2fb07c7eca54a4aa8576483c35d36"}, + {file = "ruff-0.3.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:b74c3de9103bd35df2bb05d8b2899bf2dbe4efda6474ea9681280648ec4d237d"}, + {file = "ruff-0.3.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f380be9fc15a99765c9cf316b40b9da1f6ad2ab9639e551703e581a5e6da6745"}, + {file = "ruff-0.3.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0ac06a3759c3ab9ef86bbeca665d31ad3aa9a4b1c17684aadb7e61c10baa0df4"}, + {file = "ruff-0.3.2-py3-none-win32.whl", hash = "sha256:9bd640a8f7dd07a0b6901fcebccedadeb1a705a50350fb86b4003b805c81385a"}, + {file = "ruff-0.3.2-py3-none-win_amd64.whl", hash = "sha256:0c1bdd9920cab5707c26c8b3bf33a064a4ca7842d91a99ec0634fec68f9f4037"}, + {file = "ruff-0.3.2-py3-none-win_arm64.whl", hash = "sha256:5f65103b1d76e0d600cabd577b04179ff592064eaa451a70a81085930e907d0b"}, + {file = "ruff-0.3.2.tar.gz", hash = "sha256:fa78ec9418eb1ca3db392811df3376b46471ae93792a81af2d1cbb0e5dcb5142"}, ] [[package]] From cbd2eebb86604dc3f0914c640f769ca45863c337 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:00:23 +0000 Subject: [PATCH 11/15] Bump pandas-stubs from 2.2.0.240218 to 2.2.1.240316 Bumps [pandas-stubs](https://github.com/pandas-dev/pandas-stubs) from 2.2.0.240218 to 2.2.1.240316. - [Changelog](https://github.com/pandas-dev/pandas-stubs/blob/main/docs/release_procedure.md) - [Commits](https://github.com/pandas-dev/pandas-stubs/compare/v2.2.0.240218...v2.2.1.240316) --- updated-dependencies: - dependency-name: pandas-stubs dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2bcafd10..6313520c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -776,13 +776,13 @@ test = ["hypothesis (>=5.5.3)", "pytest (>=6.0)", "pytest-xdist (>=1.31)"] [[package]] name = "pandas-stubs" -version = "2.2.0.240218" +version = "2.2.1.240316" description = "Type annotations for pandas" optional = false python-versions = ">=3.9" files = [ - {file = "pandas_stubs-2.2.0.240218-py3-none-any.whl", hash = "sha256:e97478320add9b958391b15a56c5f1bf29da656d5b747d28bbe708454b3a1fe6"}, - {file = "pandas_stubs-2.2.0.240218.tar.gz", hash = "sha256:63138c12eec715d66d48611bdd922f31cd7c78bcadd19384c3bd61fd3720a11a"}, + {file = "pandas_stubs-2.2.1.240316-py3-none-any.whl", hash = "sha256:0126a26451a37cb893ea62357ca87ba3d181bd999ec8ba2ca5602e20207d6682"}, + {file = "pandas_stubs-2.2.1.240316.tar.gz", hash = "sha256:236a4f812fb6b1922e9607ff09e427f6d8540c421c9e5a40e3e4ddf7adac7f05"}, ] [package.dependencies] From e7efde7fe14e67076f7bb904ec10721476dc04c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:01:18 +0000 Subject: [PATCH 12/15] Bump neoconfigen from 2.4.2 to 2.5.0 Bumps [neoconfigen](https://github.com/predictive-analytics-lab/neoconfigen) from 2.4.2 to 2.5.0. - [Release notes](https://github.com/predictive-analytics-lab/neoconfigen/releases) - [Commits](https://github.com/predictive-analytics-lab/neoconfigen/compare/v2.4.2...v2.5.0) --- updated-dependencies: - dependency-name: neoconfigen dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2bcafd10..97e0d7d6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -609,13 +609,13 @@ files = [ [[package]] name = "neoconfigen" -version = "2.4.2" +version = "2.5.0" description = "A fork of hydra-core's configen with extended type-compatibility." optional = true -python-versions = ">=3.9,<3.13" +python-versions = ">=3.10,<3.13" files = [ - {file = "neoconfigen-2.4.2-py3-none-any.whl", hash = "sha256:0059024f1558a2193d0b790514b17ffa727ea1eac90fd580b52ebccf5cc88ce9"}, - {file = "neoconfigen-2.4.2.tar.gz", hash = "sha256:b5644ecbb4b2961c1defab53ad0eaa201744e6303ed9aec32660bca52ffd0ba4"}, + {file = "neoconfigen-2.5.0-py3-none-any.whl", hash = "sha256:36d7b87dbfe3405a82fe3a2c3f03d2f016cc04abfed764deb98aa047991f907a"}, + {file = "neoconfigen-2.5.0.tar.gz", hash = "sha256:90b82bfa8f157279732438cec5f1580d5c034a56e846245ae6fb12b0c0f90dfa"}, ] [package.dependencies] From d7de52bc3379f2fc248d917f8074eb43ff20d628 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 07:02:25 +0000 Subject: [PATCH 13/15] Bump ruff from 0.3.2 to 0.3.3 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.2 to 0.3.3. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.2...v0.3.3) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index 2bcafd10..10e938d3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1048,28 +1048,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.3.2" +version = "0.3.3" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.3.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:77f2612752e25f730da7421ca5e3147b213dca4f9a0f7e0b534e9562c5441f01"}, - {file = "ruff-0.3.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9966b964b2dd1107797be9ca7195002b874424d1d5472097701ae8f43eadef5d"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b83d17ff166aa0659d1e1deaf9f2f14cbe387293a906de09bc4860717eb2e2da"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:bb875c6cc87b3703aeda85f01c9aebdce3d217aeaca3c2e52e38077383f7268a"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:be75e468a6a86426430373d81c041b7605137a28f7014a72d2fc749e47f572aa"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:967978ac2d4506255e2f52afe70dda023fc602b283e97685c8447d036863a302"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1231eacd4510f73222940727ac927bc5d07667a86b0cbe822024dd00343e77e9"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2c6d613b19e9a8021be2ee1d0e27710208d1603b56f47203d0abbde906929a9b"}, - {file = "ruff-0.3.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c8439338a6303585d27b66b4626cbde89bb3e50fa3cae86ce52c1db7449330a7"}, - {file = "ruff-0.3.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:de8b480d8379620cbb5ea466a9e53bb467d2fb07c7eca54a4aa8576483c35d36"}, - {file = "ruff-0.3.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:b74c3de9103bd35df2bb05d8b2899bf2dbe4efda6474ea9681280648ec4d237d"}, - {file = "ruff-0.3.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f380be9fc15a99765c9cf316b40b9da1f6ad2ab9639e551703e581a5e6da6745"}, - {file = "ruff-0.3.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0ac06a3759c3ab9ef86bbeca665d31ad3aa9a4b1c17684aadb7e61c10baa0df4"}, - {file = "ruff-0.3.2-py3-none-win32.whl", hash = "sha256:9bd640a8f7dd07a0b6901fcebccedadeb1a705a50350fb86b4003b805c81385a"}, - {file = "ruff-0.3.2-py3-none-win_amd64.whl", hash = "sha256:0c1bdd9920cab5707c26c8b3bf33a064a4ca7842d91a99ec0634fec68f9f4037"}, - {file = "ruff-0.3.2-py3-none-win_arm64.whl", hash = "sha256:5f65103b1d76e0d600cabd577b04179ff592064eaa451a70a81085930e907d0b"}, - {file = "ruff-0.3.2.tar.gz", hash = "sha256:fa78ec9418eb1ca3db392811df3376b46471ae93792a81af2d1cbb0e5dcb5142"}, + {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:973a0e388b7bc2e9148c7f9be8b8c6ae7471b9be37e1cc732f8f44a6f6d7720d"}, + {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfa60d23269d6e2031129b053fdb4e5a7b0637fc6c9c0586737b962b2f834493"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1eca7ff7a47043cf6ce5c7f45f603b09121a7cc047447744b029d1b719278eb5"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7d3f6762217c1da954de24b4a1a70515630d29f71e268ec5000afe81377642d"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b24c19e8598916d9c6f5a5437671f55ee93c212a2c4c569605dc3842b6820386"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5a6cbf216b69c7090f0fe4669501a27326c34e119068c1494f35aaf4cc683778"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:352e95ead6964974b234e16ba8a66dad102ec7bf8ac064a23f95371d8b198aab"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d6ab88c81c4040a817aa432484e838aaddf8bfd7ca70e4e615482757acb64f8"}, + {file = "ruff-0.3.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79bca3a03a759cc773fca69e0bdeac8abd1c13c31b798d5bb3c9da4a03144a9f"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2700a804d5336bcffe063fd789ca2c7b02b552d2e323a336700abb8ae9e6a3f8"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fd66469f1a18fdb9d32e22b79f486223052ddf057dc56dea0caaf1a47bdfaf4e"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:45817af234605525cdf6317005923bf532514e1ea3d9270acf61ca2440691376"}, + {file = "ruff-0.3.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0da458989ce0159555ef224d5b7c24d3d2e4bf4c300b85467b08c3261c6bc6a8"}, + {file = "ruff-0.3.3-py3-none-win32.whl", hash = "sha256:f2831ec6a580a97f1ea82ea1eda0401c3cdf512cf2045fa3c85e8ef109e87de0"}, + {file = "ruff-0.3.3-py3-none-win_amd64.whl", hash = "sha256:be90bcae57c24d9f9d023b12d627e958eb55f595428bafcb7fec0791ad25ddfc"}, + {file = "ruff-0.3.3-py3-none-win_arm64.whl", hash = "sha256:0171aab5fecdc54383993389710a3d1227f2da124d76a2784a7098e818f92d61"}, + {file = "ruff-0.3.3.tar.gz", hash = "sha256:38671be06f57a2f8aba957d9f701ea889aa5736be806f18c0cd03d6ff0cbca8d"}, ] [[package]] From d132ededf73b5573190f86fac39939769297a36e Mon Sep 17 00:00:00 2001 From: Thomas M Kehrenberg Date: Sat, 23 Mar 2024 17:15:12 +0100 Subject: [PATCH 14/15] Allow subclassing in hydra config classes --- ranzen/hydra/utils.py | 75 ++++++++++++++++--------- tests/hydra_test.py | 126 ++++++++++++++++++------------------------ 2 files changed, 102 insertions(+), 99 deletions(-) diff --git a/ranzen/hydra/utils.py b/ranzen/hydra/utils.py index ea0d0cf6..2bdc1ef5 100644 --- a/ranzen/hydra/utils.py +++ b/ranzen/hydra/utils.py @@ -3,14 +3,12 @@ from collections.abc import Iterator, MutableMapping, Sequence from contextlib import contextmanager import dataclasses -from dataclasses import MISSING, Field, asdict, is_dataclass +from dataclasses import MISSING, asdict, is_dataclass from enum import Enum import shlex -from typing import Any, Final, Union, cast +from typing import Any, Final, cast, get_args from typing_extensions import deprecated -import attrs -from attrs import NOTHING, Attribute from hydra.core.config_store import ConfigStore from hydra.core.hydra_config import HydraConfig from hydra.utils import instantiate @@ -174,38 +172,61 @@ class Config: register_hydra_config(Config, groups) """ assert isinstance(main_cls, type), "`main_cls` has to be a type." - configs: Union[tuple[Attribute, ...], tuple[Field, ...]] - is_dc = is_dataclass(main_cls) - if is_dc: - configs = dataclasses.fields(main_cls) - elif attrs.has(main_cls): - configs = attrs.fields(main_cls) - else: - raise ValueError( - f"The given class {main_cls.__name__} is neither a dataclass nor an attrs class." - ) - ABSENT = MISSING if is_dc else NOTHING + if not is_dataclass(main_cls): + raise ValueError(f"The config class {main_cls.__name__} should be a dataclass.") + configs = dataclasses.fields(main_cls) for config in configs: if config.type == Any or (isinstance(typ := config.type, str) and typ == "Any"): - if config.name not in groups: - raise ValueError(f"{IF} type Any, {NEED} variants: `{config.name}`") - if config.default is not ABSENT or ( - isinstance(config, Field) and config.default_factory is not ABSENT - ): - raise ValueError(f"{IF} type Any, {NEED} no default value: `{config.name}`") - else: if config.name in groups: - raise ValueError(f"{IF} a real type, {NEED} no variants: `{config.name}`") - if config.default is ABSENT and not ( - isinstance(config, Field) and config.default_factory is not ABSENT - ): - raise ValueError(f"{IF} a real type, {NEED} a default value: `{config.name}`") + for name, variant in groups[config.name].items(): + if not is_dataclass(variant): + raise ValueError( + f"All variants should be dataclasses: `{variant.__name__}` " + f"of variant `{config.name}={name}` is not a dataclass." + ) + else: + raise ValueError(f"{IF} type `Any`, {NEED} variants: `{config.name}`") + if config.default is not MISSING or config.default_factory is not MISSING: + raise ValueError(f"{IF} type `Any`, {NEED} no default value: `{config.name}`") + else: + if is_dataclass(config.type): + if config.default is MISSING and config.default_factory is MISSING: + if config.name not in groups: + raise ValueError( + f"{IF} a dataclass type, " + f"{NEED} a default value or registered variants: `{config.name}`." + "You can specify a default value with `field(default_factory=...)`." + ) + else: + for name, variant in groups[config.name].items(): + if not issubclass(variant, config.type): + raise ValueError( + f"All variants should be subclasses of their entry's type: " + f"type `{variant.__name__}` of variant `{config.name}={name}` " + f"is not a subclass of `{config.type.__name__}`." + ) + else: + if config.name in groups: + raise ValueError( + f"Can't have both a default value and variants: `{config.name}`" + ) + elif config.name in groups: + raise ValueError( + f"Entry `{config.name}` has registered variants, but its type, " + f"`{config.type.__name__}`, is not a dataclass." + ) cs = ConfigStore.instance() cs.store(node=main_cls, name=schema_name) for group, entries in groups.items(): for name, node in entries.items(): + if (bases := getattr(node, "__orig_bases__", None)) is not None: + if len(bases) > 0 and len(get_args(bases[0])) > 0: + raise ValueError( + f"Can't register a dataclass with generic base class: `{node.__name__}` " + f"with base class `{bases[0].__name__}`." + ) try: cs.store(node=node, name=name, group=group) except Exception as exc: diff --git a/tests/hydra_test.py b/tests/hydra_test.py index 0ac38d32..499d88eb 100644 --- a/tests/hydra_test.py +++ b/tests/hydra_test.py @@ -2,17 +2,15 @@ from dataclasses import dataclass from enum import Enum, auto from pathlib import Path -from typing import Any +from typing import Any, Generic, TypeVar -import attrs -from attrs import define from omegaconf import MISSING, DictConfig, MissingMandatoryValue, OmegaConf import pytest from ranzen.hydra import prepare_for_logging, register_hydra_config -def test_dataclass_no_default() -> None: +def test_config_no_default() -> None: """This isn't so much wrong as just clumsy.""" @dataclass @@ -28,11 +26,18 @@ class Config: register_hydra_config(Config, options) options = {"dm": {"base": DataModule}} + register_hydra_config(Config, options) + + @dataclass + class UnrelatedClass: + root: Path + + options = {"dm": {"base": UnrelatedClass}} with pytest.raises(ValueError): register_hydra_config(Config, options) -def test_dataclass_any() -> None: +def test_config_any() -> None: @dataclass class DataModule: root: Path @@ -50,54 +55,28 @@ class Config: options = {"dm": {"base": DataModule}} register_hydra_config(Config, options) + class NotDC: + x: int -def test_dataclass_any_with_default() -> None: - """An Any field with default is completely out.""" - - @dataclass - class Model: - layers: int = 1 - - @dataclass - class Config: - model: Any = dataclasses.field(default_factory=Model) - - options = {} - with pytest.raises(ValueError): - register_hydra_config(Config, options) - - options = {"model": {"base": Model}} + options = {"dm": {"base": NotDC}} with pytest.raises(ValueError): register_hydra_config(Config, options) -def test_dataclass_with_default() -> None: - """A normal field with a default should not have variants.""" - +def test_config_base_class() -> None: @dataclass - class Model: - layers: int = 1 + class DataModule: + root: Path @dataclass - class Config: - model: Model = dataclasses.field(default_factory=Model) + class CMnist(DataModule): + colorize: bool - options = {} - register_hydra_config(Config, options) - - options = {"model": {"base": Model}} - with pytest.raises(ValueError): - register_hydra_config(Config, options) - - -def test_attrs_no_default() -> None: - """This isn't so much wrong as just clumsy.""" - - @define - class DataModule: - root: Path + @dataclass + class CelebA(DataModule): + target: str - @define + @dataclass class Config: dm: DataModule @@ -105,42 +84,28 @@ class Config: with pytest.raises(ValueError): register_hydra_config(Config, options) - options = {"dm": {"base": DataModule}} - with pytest.raises(ValueError): - register_hydra_config(Config, options) - + options = {"dm": {"cmnist": CMnist, "celeba": CelebA}} + register_hydra_config(Config, options) -def test_attrs_any() -> None: - @define - class DataModule: + @dataclass + class NotSubclass: root: Path - @define - class Config: - dm: Any - - # we're assuming that the only reason you want to use Any is that - # you want to use variants - options = {} + options = {"dm": {"base": NotSubclass}} with pytest.raises(ValueError): register_hydra_config(Config, options) - options = {"dm": {"base": DataModule}} - register_hydra_config(Config, options) - -def test_attrs_any_with_default() -> None: +def test_config_any_with_default() -> None: """An Any field with default is completely out.""" - @define + @dataclass class Model: layers: int = 1 - @define + @dataclass class Config: - # it should of course be `factory` and not `default` here, - # but OmegaConf is stupid as always - model: Any = attrs.field(default=Model) + model: Any = dataclasses.field(default_factory=Model) options = {} with pytest.raises(ValueError): @@ -151,18 +116,16 @@ class Config: register_hydra_config(Config, options) -def test_attrs_with_default() -> None: +def test_config_with_default() -> None: """A normal field with a default should not have variants.""" - @define + @dataclass class Model: layers: int = 1 - @define + @dataclass class Config: - # it should of course be `factory` and not `default` here, - # but OmegaConf is stupid as always - model: Model = attrs.field(default=Model) + model: Model = dataclasses.field(default_factory=Model) options = {} register_hydra_config(Config, options) @@ -172,6 +135,25 @@ class Config: register_hydra_config(Config, options) +T = TypeVar("T") + + +def test_config_generic() -> None: + class Base(Generic[T]): ... + + @dataclass + class DataModule(Base): + root: Path + + @dataclass + class Config: + dm: DataModule + + options = {"dm": {"asdf": DataModule}} + with pytest.raises(ValueError): + register_hydra_config(Config, options) + + def test_logging_dict() -> None: class TrainingType(Enum): iter = auto() From 840252939f1fc16b6d539a8d0b26482f8aef0845 Mon Sep 17 00:00:00 2001 From: Thomas M Kehrenberg Date: Sat, 23 Mar 2024 17:32:29 +0100 Subject: [PATCH 15/15] Make code prettier and handle stringized annotations correctly --- ranzen/hydra/utils.py | 79 +++++++++++++++++++++++-------------------- tests/hydra_test.py | 39 +++++++++++++++++++++ 2 files changed, 82 insertions(+), 36 deletions(-) diff --git a/ranzen/hydra/utils.py b/ranzen/hydra/utils.py index 2bdc1ef5..db9a0152 100644 --- a/ranzen/hydra/utils.py +++ b/ranzen/hydra/utils.py @@ -6,7 +6,7 @@ from dataclasses import MISSING, asdict, is_dataclass from enum import Enum import shlex -from typing import Any, Final, cast, get_args +from typing import Any, Final, cast, get_args, get_type_hints from typing_extensions import deprecated from hydra.core.config_store import ConfigStore @@ -174,60 +174,67 @@ class Config: assert isinstance(main_cls, type), "`main_cls` has to be a type." if not is_dataclass(main_cls): raise ValueError(f"The config class {main_cls.__name__} should be a dataclass.") - configs = dataclasses.fields(main_cls) - - for config in configs: - if config.type == Any or (isinstance(typ := config.type, str) and typ == "Any"): - if config.name in groups: - for name, variant in groups[config.name].items(): - if not is_dataclass(variant): + entries = dataclasses.fields(main_cls) + try: + types = get_type_hints(main_cls) + except NameError as exc: + raise ValueError( + f"Can't resolve type hints from the config class: `{main_cls.__name__}`." + ) from exc + + for entry in entries: + typ = types[entry.name] + if typ == Any: + if (group := groups.get(entry.name)) is not None: + for var_name, var_class in group.items(): + if not is_dataclass(var_class): raise ValueError( - f"All variants should be dataclasses: `{variant.__name__}` " - f"of variant `{config.name}={name}` is not a dataclass." + f"All variants should be dataclasses: type `{var_class.__name__}` " + f"of variant `{entry.name}={var_name}` is not a dataclass." ) else: - raise ValueError(f"{IF} type `Any`, {NEED} variants: `{config.name}`") - if config.default is not MISSING or config.default_factory is not MISSING: - raise ValueError(f"{IF} type `Any`, {NEED} no default value: `{config.name}`") + raise ValueError(f"{IF} type `Any`, {NEED} variants: `{entry.name}`") + if entry.default is not MISSING or entry.default_factory is not MISSING: + raise ValueError(f"{IF} type `Any`, {NEED} no default value: `{entry.name}`") else: - if is_dataclass(config.type): - if config.default is MISSING and config.default_factory is MISSING: - if config.name not in groups: + if is_dataclass(typ): + if entry.default is MISSING and entry.default_factory is MISSING: + if (group := groups.get(entry.name)) is not None: + for var_name, var_class in group.items(): + if not issubclass(var_class, typ): + raise ValueError( + f"All variants should be subclasses of their entry's type: type" + f" `{var_class.__name__}` of variant `{entry.name}={var_name}` " + f"is not a subclass of `{typ.__name__}`." + ) + else: raise ValueError( f"{IF} a dataclass type, " - f"{NEED} a default value or registered variants: `{config.name}`." + f"{NEED} a default value or registered variants: `{entry.name}`. " "You can specify a default value with `field(default_factory=...)`." ) - else: - for name, variant in groups[config.name].items(): - if not issubclass(variant, config.type): - raise ValueError( - f"All variants should be subclasses of their entry's type: " - f"type `{variant.__name__}` of variant `{config.name}={name}` " - f"is not a subclass of `{config.type.__name__}`." - ) else: - if config.name in groups: + if entry.name in groups: raise ValueError( - f"Can't have both a default value and variants: `{config.name}`" + f"Can't have both a default value and variants: `{entry.name}`." ) - elif config.name in groups: + elif entry.name in groups: raise ValueError( - f"Entry `{config.name}` has registered variants, but its type, " - f"`{config.type.__name__}`, is not a dataclass." + f"Entry `{entry.name}` has registered variants, but its type, " + f"`{entry.type.__name__}`, is not a dataclass." ) cs = ConfigStore.instance() cs.store(node=main_cls, name=schema_name) for group, entries in groups.items(): - for name, node in entries.items(): - if (bases := getattr(node, "__orig_bases__", None)) is not None: + for var_name, var_type in entries.items(): + if (bases := getattr(var_type, "__orig_bases__", None)) is not None: if len(bases) > 0 and len(get_args(bases[0])) > 0: raise ValueError( - f"Can't register a dataclass with generic base class: `{node.__name__}` " - f"with base class `{bases[0].__name__}`." + f"Can't register a dataclass with generic base class: `{var_type.__name__}`" + f" with base class `{bases[0].__name__}`." ) try: - cs.store(node=node, name=name, group=group) + cs.store(node=var_type, name=var_name, group=group) except Exception as exc: - raise RuntimeError(f"{main_cls=}, {node=}, {name=}, {group=}") from exc + raise RuntimeError(f"{main_cls=}, {var_type=}, {var_name=}, {group=}") from exc diff --git a/tests/hydra_test.py b/tests/hydra_test.py index 499d88eb..7a8cbbe8 100644 --- a/tests/hydra_test.py +++ b/tests/hydra_test.py @@ -63,6 +63,25 @@ class NotDC: register_hydra_config(Config, options) +def test_config_any_string() -> None: + @dataclass + class DataModule: + root: Path + + @dataclass + class Config: + dm: "Any" + + # we're assuming that the only reason you want to use Any is that + # you want to use variants + options = {} + with pytest.raises(ValueError): + register_hydra_config(Config, options) + + options = {"dm": {"base": DataModule}} + register_hydra_config(Config, options) + + def test_config_base_class() -> None: @dataclass class DataModule: @@ -135,6 +154,26 @@ class Config: register_hydra_config(Config, options) +@dataclass +class _GlobalModel: + layers: int = 1 + + +def test_config_with_default_string() -> None: + """Need to use a global class here because otherwise the type annotations can'b be resolved.""" + + @dataclass + class Config: + model: "_GlobalModel" = dataclasses.field(default_factory=_GlobalModel) + + options = {} + register_hydra_config(Config, options) + + options = {"model": {"base": _GlobalModel}} + with pytest.raises(ValueError): + register_hydra_config(Config, options) + + T = TypeVar("T")