Skip to content

Commit

Permalink
[#624][[#617] Switch to and require pydantic 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
nabla-c0d3 committed Feb 24, 2024
1 parent 49380c1 commit 410ac01
Show file tree
Hide file tree
Showing 35 changed files with 2,093 additions and 18,814 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# TODO(#617): Delete this file
name: Run tests with pydantic 1.10
name: Run tests with lowest supported version of pydantic

on:
push:
Expand All @@ -16,15 +15,15 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8

- name: Install sslyze dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -e .
- name: Install pydantic 1.10
run: python -m pip install "pydantic<2"
- name: Install pydantic 2.2
run: python -m pip install "pydantic==2.2"

- name: Install dev dependencies
run: python -m pip install -r requirements-dev.txt
Expand Down
6 changes: 3 additions & 3 deletions api_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ def example_json_result_output(
date_scans_completed: datetime,
) -> None:
json_output = SslyzeOutputAsJson(
server_scan_results=[ServerScanResultAsJson.from_orm(result) for result in all_server_scan_results],
server_scan_results=[ServerScanResultAsJson.model_validate(result) for result in all_server_scan_results],
invalid_server_strings=[], # Not needed here - specific to the CLI interface
date_scans_started=date_scans_started,
date_scans_completed=date_scans_completed,
)
json_output_as_str = json_output.json() # TODO(#617): Switch to model_dump_json()
json_output_as_str = json_output.model_dump_json()
json_file_out.write_text(json_output_as_str)


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

# These results can be parsed
parsed_results = SslyzeOutputAsJson.parse_raw(results_as_json)
parsed_results = SslyzeOutputAsJson.model_validate_json(results_as_json)

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

0 comments on commit 410ac01

Please sign in to comment.