Skip to content

Commit

Permalink
sigstore_rekor_types: don't use PEP 604 syntax in models
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <william@trailofbits.com>
  • Loading branch information
woodruffw committed Oct 4, 2023
1 parent 40fee41 commit 57cae60
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 38 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ warn_unused_ignores = true
[tool.ruff]
line-length = 100
select = ["ALL"]
target-version = "py38"

[tool.ruff.per-file-ignores]
"sigstore_rekor_types/_internal/*.py" = [
"A003", # some fields shadow python builtins
"A003", # some fields shadow python builtins
"UP007", # pydantic doesn't support PEP 604 below Python 3.10
]
"test/**/*.py" = [
"D", # no docstrings in tests
Expand Down
2 changes: 1 addition & 1 deletion sigstore_rekor_types/_internal/alpine.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:55+00:00
# timestamp: 2023-10-04T14:54:07+00:00

from __future__ import annotations

Expand Down
11 changes: 6 additions & 5 deletions sigstore_rekor_types/_internal/cose.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:55+00:00
# timestamp: 2023-10-04T14:54:07+00:00

from __future__ import annotations

from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field, RootModel, StrictStr

Expand All @@ -29,24 +30,24 @@ class EnvelopeHash(BaseModel):


class Data(BaseModel):
payload_hash: PayloadHash | None = Field(
payload_hash: Optional[PayloadHash] = Field(
None,
alias="payloadHash",
description="Specifies the hash algorithm and value for the content",
)
envelope_hash: EnvelopeHash | None = Field(
envelope_hash: Optional[EnvelopeHash] = Field(
None,
alias="envelopeHash",
description="Specifies the hash algorithm and value for the COSE envelope",
)
aad: str | None = Field(
aad: Optional[str] = Field(
None,
description="Specifies the additional authenticated data required to verify the signature",
)


class CoseV001Schema(BaseModel):
message: str | None = Field(None, description="The COSE Sign1 Message")
message: Optional[str] = Field(None, description="The COSE Sign1 Message")
public_key: str = Field(
...,
alias="publicKey",
Expand Down
11 changes: 6 additions & 5 deletions sigstore_rekor_types/_internal/dsse.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:56+00:00
# timestamp: 2023-10-04T14:54:07+00:00

from __future__ import annotations

from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field, RootModel, StrictStr

Expand Down Expand Up @@ -61,23 +62,23 @@ class PayloadHash(BaseModel):


class DsseV001Schema(BaseModel):
proposed_content: ProposedContent | None = Field(None, alias="proposedContent")
signatures: list[Signature] | None = Field(
proposed_content: Optional[ProposedContent] = Field(None, alias="proposedContent")
signatures: Optional[list[Signature]] = Field(
None,
description=(
"extracted collection of all signatures of the envelope's payload; elements will be"
" sorted by lexicographical order of the base64 encoded signature strings"
),
min_length=1,
)
envelope_hash: EnvelopeHash | None = Field(
envelope_hash: Optional[EnvelopeHash] = Field(
None,
alias="envelopeHash",
description=(
"Specifies the hash algorithm and value encompassing the entire envelope sent to Rekor"
),
)
payload_hash: PayloadHash | None = Field(
payload_hash: Optional[PayloadHash] = Field(
None,
alias="payloadHash",
description=(
Expand Down
11 changes: 6 additions & 5 deletions sigstore_rekor_types/_internal/hashedrekord.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:56+00:00
# timestamp: 2023-10-04T14:54:08+00:00

from __future__ import annotations

from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field, RootModel, StrictStr


class PublicKey(BaseModel):
content: str | None = Field(
content: Optional[str] = Field(
None,
description=(
"Specifies the content of the public key or code signing certificate inline within the"
Expand All @@ -19,11 +20,11 @@ class PublicKey(BaseModel):


class Signature(BaseModel):
content: str | None = Field(
content: Optional[str] = Field(
None,
description="Specifies the content of the signature inline within the document",
)
public_key: PublicKey | None = Field(
public_key: Optional[PublicKey] = Field(
None,
alias="publicKey",
description=(
Expand All @@ -46,7 +47,7 @@ class Hash(BaseModel):


class Data(BaseModel):
hash: Hash | None = Field(
hash: Optional[Hash] = Field(
None,
description="Specifies the hash algorithm and value for the content",
)
Expand Down
5 changes: 3 additions & 2 deletions sigstore_rekor_types/_internal/helm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:56+00:00
# timestamp: 2023-10-04T14:54:08+00:00

from __future__ import annotations

from enum import Enum
from typing import Optional

from pydantic import BaseModel, Field, RootModel, StrictStr

Expand All @@ -28,7 +29,7 @@ class Hash(BaseModel):


class Chart(BaseModel):
hash: Hash | None = Field(
hash: Optional[Hash] = Field(
None,
description="Specifies the hash algorithm and value for the chart",
)
Expand Down
20 changes: 10 additions & 10 deletions sigstore_rekor_types/_internal/intoto.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:56+00:00
# timestamp: 2023-10-04T14:54:08+00:00

from __future__ import annotations

from enum import Enum
from typing import Union
from typing import Optional, Union

from pydantic import BaseModel, Field, RootModel, StrictStr

Expand All @@ -30,15 +30,15 @@ class PayloadHash(BaseModel):


class Content(BaseModel):
envelope: StrictStr | None = Field(None, description="envelope")
hash: Hash | None = Field(
envelope: Optional[StrictStr] = Field(None, description="envelope")
hash: Optional[Hash] = Field(
None,
description=(
"Specifies the hash algorithm and value encompassing the entire signed envelope; this"
" is computed by the rekor server, client-provided values are ignored"
),
)
payload_hash: PayloadHash | None = Field(
payload_hash: Optional[PayloadHash] = Field(
None,
alias="payloadHash",
description=(
Expand All @@ -58,7 +58,7 @@ class IntotoV001Schema(BaseModel):


class Signature(BaseModel):
keyid: StrictStr | None = Field(
keyid: Optional[StrictStr] = Field(
None,
description="optional id of the key used to create the signature",
)
Expand All @@ -71,7 +71,7 @@ class Signature(BaseModel):


class Envelope(BaseModel):
payload: str | None = Field(None, description="payload of the envelope")
payload: Optional[str] = Field(None, description="payload of the envelope")
payload_type: StrictStr = Field(
...,
alias="payloadType",
Expand Down Expand Up @@ -102,13 +102,13 @@ class PayloadHash1(BaseModel):

class Content1(BaseModel):
envelope: Envelope = Field(..., description="dsse envelope")
hash: Hash1 | None = Field(
hash: Optional[Hash1] = Field(
None,
description=(
"Specifies the hash algorithm and value encompassing the entire signed envelope"
),
)
payload_hash: PayloadHash1 | None = Field(
payload_hash: Optional[PayloadHash1] = Field(
None,
alias="payloadHash",
description=(
Expand All @@ -122,7 +122,7 @@ class IntotoV002Schema(BaseModel):


class IntotoSchema(RootModel[Union[IntotoV001Schema, IntotoV002Schema]]):
root: IntotoV001Schema | IntotoV002Schema = Field(
root: Union[IntotoV001Schema, IntotoV002Schema] = Field(
...,
description="Intoto for Rekord objects",
title="Intoto Schema",
Expand Down
6 changes: 4 additions & 2 deletions sigstore_rekor_types/_internal/jar.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:57+00:00
# timestamp: 2023-10-04T14:54:08+00:00

from __future__ import annotations

from typing import Optional

from pydantic import BaseModel, Field, RootModel


Expand Down Expand Up @@ -32,7 +34,7 @@ class Signature(BaseModel):


class JarV001Schema(BaseModel):
signature: Signature | None = Field(
signature: Optional[Signature] = Field(
None,
description="Information about the included signature in the JAR file",
)
Expand Down
2 changes: 1 addition & 1 deletion sigstore_rekor_types/_internal/rekord.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:57+00:00
# timestamp: 2023-10-04T14:54:09+00:00

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion sigstore_rekor_types/_internal/rfc3161.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:57+00:00
# timestamp: 2023-10-04T14:54:09+00:00

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion sigstore_rekor_types/_internal/rpm.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:57+00:00
# timestamp: 2023-10-04T14:54:09+00:00

from __future__ import annotations

Expand Down
6 changes: 3 additions & 3 deletions sigstore_rekor_types/_internal/tuf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# generated by datamodel-codegen:
# timestamp: 2023-10-03T20:01:58+00:00
# timestamp: 2023-10-04T14:54:10+00:00

from __future__ import annotations

from typing import Any
from typing import Any, Optional

from pydantic import BaseModel, Field, RootModel, StrictStr

Expand All @@ -23,7 +23,7 @@ class Root(BaseModel):


class TufV001Schema(BaseModel):
spec_version: StrictStr | None = Field(None, description="TUF specification version")
spec_version: Optional[StrictStr] = Field(None, description="TUF specification version")
metadata: Metadata = Field(..., description="TUF metadata")
root: Root = Field(
...,
Expand Down

0 comments on commit 57cae60

Please sign in to comment.