Skip to content

Commit 360b922

Browse files
authored
feat(DEVC-1282): migrate SDK to v2 (#110)
* feat: remove redis ping * feat(DEVC-265): add py-typed file & update pyproject.toml accordingly * feat(DEVC-265): ensure that lint passed; bump mypy version from mypy==0.950 -> mypy>=1.10,<2 * feat(DEVC-265): move mypy CLI args into single place - pyproject.toml file * feat(DEVC-265): remove exclude block at mypy settings for skipping some docs/modules tutorials * feat(DEVC-265): optimise mypy config * feat(DEVC-1282): migrate SDK code to pydantic V2 * feat(DEVC-1282): migrate tests to pydantic v2 as well; add some fixes * feat(DEVC-1282): improve type annotations; refactor RerunTimeRange class validators at to simplify * feat(DEVC-1282): fix annotations for `model_validator` with mode="before" * feat(DEVC-1282): set new minor version * feat(DEVC-1286): Revamp redis usage (#111) - upgrade redis version for test server - bump bunch of related third party dependencies: - fakeredis[lua] -> removed prefix LUA - redis == 6.2.0 latest supported with Python3.9+ - types-redis~=4.6.0 - removed: - all LUA bindings from RedisRepository - use_lua_52 - vacuum(...) and dependant codes - InternalCacheSdkProtocol - InternalRedisSdk - FakeInternalCacheSdk - DeprecatedRedisAdapter - Add migration logic
1 parent 0dc0500 commit 360b922

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+724
-1159
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.0.0] - 2025-09-11
10+
### Changed
11+
- Full migration from old `v1`of `pydantic` to `v2`dependencies:
12+
- `pydantic` itself: `"pydantic >= 2.0, <3.0"`
13+
- `pydantic-settings`: `"pydantic-settings >=2.0, <3.0"`
14+
- Revamp Redis, get rid of LUA scripts at all
15+
- Add `py.typed` for type checking
16+
- Upgrading a bunch of dependencies
17+
18+
919
## [1.15.0] - 2025-09-04
1020
### Security
1121
- Upgraded internal dependency `urllib3` to version `2.5.0`

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ coverage-html: test
5858
.PHONY: lint
5959
lint:
6060
@ruff check $(srcs)
61-
@mypy --check-untyped-defs $(srcs)
61+
@mypy $(srcs)
6262

6363
## format: Format all files.
6464
.PHONY: format
@@ -112,7 +112,7 @@ up-cache:
112112
-d \
113113
--name python-sdk-redis \
114114
-p 6379:6379 \
115-
redis:6.0.9 # apps use 6.0.9 or 6.2.3
115+
redis:7.4.0
116116

117117
# down-cache: Stop Redis.
118118
.PHONY: down-cache

docs/antora-playbook.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ content:
77
start_path: docs
88
branches: []
99
# branches: HEAD # Use this for local development
10-
tags: [v1.15.0]
10+
tags: [v2.0.0]
1111
asciidoc:
1212
attributes:
1313
page-toclevels: 5

docs/modules/ROOT/examples/cache/tutorial002.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55

66
@scheduled
77
def scheduled_app(event: ScheduledDataTimeEvent, api: Api, cache: Cache):
8-
cache.set(key='key', value='value', ttl=1) # <.>
8+
ttl_value = 1
9+
cache.set(key='key', value='value', ttl=ttl_value) # <.>
10+
911
assert cache.get('key') == 'value'
1012

11-
time.sleep(1) # <.>
13+
time.sleep(ttl_value + 0.01) # <.>
1214

1315
assert cache.get('key') is None # <.>

docs/modules/ROOT/examples/cache/tutorial006.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ def scheduled_app(event: ScheduledDataTimeEvent, api: Api, cache: Cache):
2626
'key_with_custom_expiry': 'value_2',
2727
}
2828

29-
time.sleep(1) # <.>
29+
time.sleep(1 + 0.01) # <.>
3030

3131
assert cache.get_all() == {'key': 'value_1'} # <.>

docs/modules/ROOT/pages/index.adoc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,6 @@ It will try to re-send the same request again with exponential back-off for HTTP
281281
* 503
282282
* 504
283283

284-
[source,python]
285-
----
286-
include::example$api/tutorial008.py[]
287-
----
288-
289284
[#cache]
290285
== Cache
291286
Apps might need to share some data between invokes.

pyproject.toml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ build-backend = "setuptools.build_meta"
66
name = "corva-sdk"
77
description = "SDK for building Corva DevCenter Python apps."
88
readme = "README.md"
9-
version = "1.15.0"
9+
version = "2.0.0"
1010
license = { text = "The Unlicense" }
1111
authors = [
1212
{ name = "Jordan Ambra", email = "jordan.ambra@corva.ai" }
1313
]
1414
keywords = ["corva", "sdk"]
1515
requires-python = ">=3.9,<4.0"
1616
dependencies = [
17-
"fakeredis[lua] >=2.26.2, <2.30.0",
18-
"pydantic >=1.8.2, <2.0.0",
19-
"redis >=5.2.1, <6.0.0",
17+
"fakeredis >=2.30.0, <2.32.0",
18+
"pydantic >= 2.0, <3.0",
19+
"pydantic-settings >=2.0, <3.0",
20+
"redis == 6.4.0",
2021
"requests >=2.32.3, <3.0.0",
21-
"urllib3==2.5.0"
22+
"urllib3 == 2.5.0",
23+
"semver==3.0.4"
2224
]
2325
classifiers = [
2426
"Development Status :: 5 - Production/Stable",
@@ -27,7 +29,8 @@ classifiers = [
2729
"Programming Language :: Python",
2830
"Programming Language :: Python :: 3",
2931
"Programming Language :: Python :: 3.9",
30-
"Topic :: Software Development :: Libraries"
32+
"Topic :: Software Development :: Libraries",
33+
"Typing :: Typed"
3134
]
3235

3336
[project.urls]
@@ -36,9 +39,9 @@ Homepage = "https://github.com/corva-ai/python-sdk"
3639
[project.optional-dependencies]
3740
dev = [
3841
"ruff==0.12.11",
39-
"mypy==0.950",
42+
"mypy>=1.10,<2",
4043
"types-freezegun~=1.1.9",
41-
"types-redis~=4.2.4",
44+
"types-redis~=4.6.0",
4245
"types-requests~=2.27.27",
4346
"coverage==7.6.1",
4447
"freezegun==1.5.1",
@@ -48,10 +51,14 @@ dev = [
4851
]
4952

5053
[tool.setuptools]
54+
include-package-data = true
5155
package-dir = { "" = "src" }
5256
packages = { find = { where = ["src"] } }
5357
py-modules = ["plugin"]
5458

59+
[tool.setuptools.package-data]
60+
corva = ["py.typed"]
61+
5562
[project.entry-points."pytest11"]
5663
corva = "plugin"
5764

@@ -82,24 +89,26 @@ omit = [
8289
"docs/modules/ROOT/examples/logging/tutorial003.py",
8390
"docs/modules/ROOT/examples/logging/tutorial004.py",
8491
"docs/modules/ROOT/examples/logging/tutorial005.py",
92+
"docs/modules/ROOT/examples/testing/tutorial008.py",
8593
"docs/modules/ROOT/examples/followable/tutorial001.py",
8694
"src/corva/__init__.py",
8795
"src/version.py",
8896
"src/plugin.py"
8997
]
9098

9199
[tool.mypy]
92-
exclude = '''(?x)(
93-
^docs/modules/ROOT/examples/cache/tutorial004\.py$
94-
| ^docs/modules/ROOT/examples/cache/tutorial005\.py$
95-
)'''
100+
python_version = "3.9"
101+
mypy_path = "src"
102+
explicit_package_bases = true
103+
check_untyped_defs = true
96104

97105
[[tool.mypy.overrides]]
98106
module = "setuptools.*"
99107
ignore_missing_imports = true
100108

101109
[[tool.mypy.overrides]]
102110
module = "docs.*"
111+
ignore_errors = true
103112
ignore_missing_imports = true
104113

105114
[[tool.mypy.overrides]]
@@ -122,3 +131,6 @@ ignore_missing_imports = true
122131
module = "fakeredis.*"
123132
ignore_missing_imports = true
124133

134+
[[tool.mypy.overrides]]
135+
module = "tests.*"
136+
ignore_errors = true

0 commit comments

Comments
 (0)