Skip to content

Commit 410ac01

Browse files
committed
[nabla-c0d3#624][[nabla-c0d3#617] Switch to and require pydantic 2.x
1 parent 49380c1 commit 410ac01

35 files changed

+2093
-18814
lines changed

.github/workflows/run_tests_with_pydantic_1_10.yml renamed to .github/workflows/run_tests_with_lowest_pydantic_version.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# TODO(#617): Delete this file
2-
name: Run tests with pydantic 1.10
1+
name: Run tests with lowest supported version of pydantic
32

43
on:
54
push:
@@ -16,15 +15,15 @@ jobs:
1615
- name: Set up Python
1716
uses: actions/setup-python@v2
1817
with:
19-
python-version: 3.7
18+
python-version: 3.8
2019

2120
- name: Install sslyze dependencies
2221
run: |
2322
python -m pip install --upgrade pip setuptools
2423
python -m pip install -e .
2524
26-
- name: Install pydantic 1.10
27-
run: python -m pip install "pydantic<2"
25+
- name: Install pydantic 2.2
26+
run: python -m pip install "pydantic==2.2"
2827

2928
- name: Install dev dependencies
3029
run: python -m pip install -r requirements-dev.txt

api_sample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,12 @@ def example_json_result_output(
118118
date_scans_completed: datetime,
119119
) -> None:
120120
json_output = SslyzeOutputAsJson(
121-
server_scan_results=[ServerScanResultAsJson.from_orm(result) for result in all_server_scan_results],
121+
server_scan_results=[ServerScanResultAsJson.model_validate(result) for result in all_server_scan_results],
122122
invalid_server_strings=[], # Not needed here - specific to the CLI interface
123123
date_scans_started=date_scans_started,
124124
date_scans_completed=date_scans_completed,
125125
)
126-
json_output_as_str = json_output.json() # TODO(#617): Switch to model_dump_json()
126+
json_output_as_str = json_output.model_dump_json()
127127
json_file_out.write_text(json_output_as_str)
128128

129129

@@ -132,7 +132,7 @@ def example_json_result_parsing(results_as_json_file: Path) -> None:
132132
results_as_json = results_as_json_file.read_text()
133133

134134
# These results can be parsed
135-
parsed_results = SslyzeOutputAsJson.parse_raw(results_as_json)
135+
parsed_results = SslyzeOutputAsJson.model_validate_json(results_as_json)
136136

137137
# Making it easy to do post-processing and inspection of the results
138138
print("The following servers were scanned:")

0 commit comments

Comments
 (0)