Skip to content

Commit b5b1bb2

Browse files
committed
Migrate typer-slim->typer, requests->httpx, open version ranges, use Pydantic v2
1 parent dbea6c1 commit b5b1bb2

4 files changed

Lines changed: 29 additions & 33 deletions

File tree

requirements.txt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# Our libraries
2-
confection>=0.0.4,<0.2.0
3-
wasabi>=0.9.1,<1.2.0
4-
srsly>=2.4.3,<3.0.0
5-
typer-slim>=0.3.0,<1.0.0
6-
cloudpathlib>=0.7.0,<1.0.0
7-
smart-open>=5.2.1,<8.0.0
2+
confection>=1.0.0
3+
wasabi>=0.9.1
4+
srsly>=2.4.3
5+
typer>=0.3.0
6+
cloudpathlib>=0.7.0
7+
smart-open>=5.2.1
88
# Third party dependencies
9-
requests>=2.13.0,<3.0.0
10-
pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0
9+
httpx>=0.24.0
10+
pydantic>=2.0.0
1111
# Official Python utilities
1212
packaging>=20.0
1313
# Development dependencies
1414
black==22.3.0
1515
pytest>=5.2.0,!=7.1.0
1616
mypy>=1.5.0,<1.7.0; python_version >= "3.8"
17-
types-requests
1817
types-setuptools>=57.0.0
1918
ruff>=0.0.259
2019
isort>=5.12.0,<6.0; python_version > "3.7"

setup.cfg

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = weasel
3-
version = 0.4.3
3+
version = 1.0.0
44
description = Weasel: A small and easy workflow system
55
url = https://github.com/explosion/weasel/
66
author = Explosion
@@ -31,15 +31,15 @@ project_urls =
3131
[options]
3232
python_requires = >=3.7
3333
install_requires =
34-
confection>=0.0.4,<0.2.0
34+
confection>=1.0.0
3535
packaging>=20.0
36-
wasabi>=0.9.1,<1.2.0
37-
srsly>=2.4.3,<3.0.0
38-
typer-slim>=0.3.0,<1.0.0
39-
cloudpathlib>=0.7.0,<1.0.0
40-
smart-open>=5.2.1,<8.0.0
41-
requests>=2.13.0,<3.0.0
42-
pydantic>=1.7.4,!=1.8,!=1.8.1,<3.0.0
36+
wasabi>=0.9.1
37+
srsly>=2.4.3
38+
typer>=0.3.0
39+
cloudpathlib>=0.7.0
40+
smart-open>=5.2.1
41+
httpx>=0.24.0
42+
pydantic>=2.0.0
4343

4444

4545
[options.entry_points]

weasel/cli/assets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
from typing import Any, Dict, Optional
66

7-
import requests
7+
import httpx
88
import typer
99
from wasabi import msg
1010

@@ -172,7 +172,7 @@ def fetch_asset(
172172
try:
173173
download_file(url, dest_path)
174174
msg.good(f"Downloaded asset {dest}")
175-
except requests.exceptions.RequestException as e:
175+
except httpx.HTTPError as e:
176176
if Path(url).exists() and Path(url).is_file():
177177
# If it's a local file, copy to destination
178178
shutil.copy(url, str(dest_path))

weasel/schemas.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
from collections import defaultdict
22
from typing import Any, Dict, List, Optional, Type, Union
33

4-
try:
5-
from pydantic.v1 import BaseModel, Field, StrictStr, ValidationError, root_validator
6-
except ImportError:
7-
from pydantic import BaseModel, Field, StrictStr, ValidationError, root_validator # type: ignore
8-
4+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, model_validator
95
from wasabi import msg
106

117

@@ -43,15 +39,15 @@ class ProjectConfigAssetURL(BaseModel):
4339
# fmt: off
4440
dest: StrictStr = Field(..., title="Destination of downloaded asset")
4541
url: Optional[StrictStr] = Field(None, title="URL of asset")
46-
checksum: Optional[str] = Field(None, title="MD5 hash of file", regex=r"([a-fA-F\d]{32})")
42+
checksum: Optional[str] = Field(None, title="MD5 hash of file", pattern=r"([a-fA-F\d]{32})")
4743
description: StrictStr = Field("", title="Description of asset")
4844
# fmt: on
4945

5046

5147
class ProjectConfigAssetGit(BaseModel):
5248
# fmt: off
5349
git: ProjectConfigAssetGitItem = Field(..., title="Git repo information")
54-
checksum: Optional[str] = Field(None, title="MD5 hash of file", regex=r"([a-fA-F\d]{32})")
50+
checksum: Optional[str] = Field(None, title="MD5 hash of file", pattern=r"([a-fA-F\d]{32})")
5551
description: Optional[StrictStr] = Field(None, title="Description of asset")
5652
# fmt: on
5753

@@ -67,9 +63,10 @@ class ProjectConfigCommand(BaseModel):
6763
no_skip: bool = Field(False, title="Never skip this command, even if nothing changed")
6864
# fmt: on
6965

70-
class Config:
71-
title = "A single named command specified in a project config"
72-
extra = "forbid"
66+
model_config = ConfigDict(
67+
title="A single named command specified in a project config",
68+
extra="forbid",
69+
)
7370

7471

7572
class ProjectConfigSchema(BaseModel):
@@ -82,10 +79,10 @@ class ProjectConfigSchema(BaseModel):
8279
title: Optional[str] = Field(None, title="Project title")
8380
# fmt: on
8481

85-
class Config:
86-
title = "Schema for project configuration file"
82+
model_config = ConfigDict(title="Schema for project configuration file")
8783

88-
@root_validator(pre=True)
84+
@model_validator(mode="before")
85+
@classmethod
8986
def check_legacy_keys(cls, obj: Dict[str, Any]) -> Dict[str, Any]:
9087
if "spacy_version" in obj:
9188
msg.warn(

0 commit comments

Comments
 (0)