Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Rust 1.70 as MSRV #1206

Merged
merged 2 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
- id: cache-rust
name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: coverage-v2

- run: cargo install rustfilt coverage-prepare
if: steps.cache-rust.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -120,14 +118,49 @@ jobs:

- name: cache rust
uses: Swatinem/rust-cache@v2

- name: set up python
uses: actions/setup-python@v5
with:
key: ${{ matrix.os }}-v1
python-version: '3.11'

- run: pip install -r tests/requirements.txt

- run: pip install -e .
env:
RUST_BACKTRACE: 1

- run: pip freeze

- run: pytest

- run: cargo test

test-msrv:
name: test MSRV

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: set up python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: resolve MSRV
id: resolve-msrv
run:
echo MSRV=`python -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["package"]["rust-version"])'` >> $GITHUB_OUTPUT

- name: install rust MSRV
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.resolve-msrv.outputs.MSRV }}

- name: cache rust
uses: Swatinem/rust-cache@v2

- run: pip install -r tests/requirements.txt

- run: pip install -e .
Expand Down Expand Up @@ -164,8 +197,6 @@ jobs:

- name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: test-debug

- run: pip install -r tests/requirements.txt
- run: make build-dev
Expand Down Expand Up @@ -197,8 +228,6 @@ jobs:

- name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: test-pydantic-integration

- name: install deps
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/codspeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ jobs:

- name: cache rust
uses: Swatinem/rust-cache@v2
with:
key: v1

- name: Compile pydantic-core for profiling
run: make build-profiling
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ include = [
"!tests/.pytest_cache",
"!*.so",
]
rust-version = "1.70"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does setting this set the min version, or the required version?

Copy link
Contributor Author

@davidhewitt davidhewitt Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minimum version, and at the moment all this will do is cause Cargo to fail the build if the installed rust version is lower.

Future Rust versions might do more here (e.g. fail the build if we accidentally use stuff newer than this version).


[dependencies]
pyo3 = { version = "0.20.2", features = ["generate-import-lib", "num-bigint"] }
Expand Down
10 changes: 5 additions & 5 deletions src/serializers/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl GeneralFieldsSerializer {
}
}

pub fn main_to_python<'py>(
pub(crate) fn main_to_python<'py>(
&self,
py: Python<'py>,
main_iter: impl Iterator<Item = PyResult<(&'py PyAny, &'py PyAny)>>,
Expand Down Expand Up @@ -212,7 +212,7 @@ impl GeneralFieldsSerializer {
}
}

pub fn main_serde_serialize<'py, S: serde::ser::Serializer>(
pub(crate) fn main_serde_serialize<'py, S: serde::ser::Serializer>(
&self,
main_iter: impl Iterator<Item = PyResult<(&'py PyAny, &'py PyAny)>>,
expected_len: usize,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl GeneralFieldsSerializer {
Ok(map)
}

pub fn add_computed_fields_python(
pub(crate) fn add_computed_fields_python(
&self,
model: Option<&PyAny>,
output_dict: &PyDict,
Expand All @@ -275,7 +275,7 @@ impl GeneralFieldsSerializer {
Ok(())
}

pub fn add_computed_fields_json<S: serde::ser::Serializer>(
pub(crate) fn add_computed_fields_json<S: serde::ser::Serializer>(
&self,
model: Option<&PyAny>,
map: &mut S::SerializeMap,
Expand All @@ -291,7 +291,7 @@ impl GeneralFieldsSerializer {
Ok(())
}

pub fn computed_field_count(&self) -> usize {
pub(crate) fn computed_field_count(&self) -> usize {
option_length!(self.computed_fields)
}
}
Expand Down
Loading