Skip to main content

flake8-pydantic-fields

A flake8 plugin that checks that Pydantic models have default values which are Fields, and that those fields have descriptions. This encourages data documentation.

This package adds the following warnings:

  • PF001: A Pydantic field which has no default.
  • PF002: A Pydantic field with a default that is not a Field.
  • PF002: A Pydantic field which has a Field default with no description.

There are no configuration options at this time.

This package uses heuristics to determine whether a class is a Pydantic model. While this could be accomplished by running the code, that is not in the spirit of static analyzers, and it would be considerably slower.

The heuristics are:

It is not a Pydantic model if:

  • The class has no base classes.
  • The class is annotated with @dataclass.

It is a Pydantic model if:

  • The name of the base class is BaseModel or GenericModel.
  • The class contains only annotated assignments.
  • The class has at least one method decorated with @validator or @root_validator.
  • The class contains an inner Config class.
  • The class contains only methods with no arguments other than self. These are assumed to be transformations on a data model.
  • The class contains an attribute annotated as a ClassVar.

Metadata

Release files for flake8-pydantic-fields 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-pydantic-fields 0.1.11
File Size Uploaded Provenance Actions
flake8-pydantic-fields-0.1.11.tar.gz 4.2 kB Without provenance Details for flake8-pydantic-fields-0.1.11.tar.gz

Release files / flake8-pydantic-fields-0.1.11.tar.gz

Download URL flake8-pydantic-fields-0.1.11.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1c3f1662f67af9cccccb46cd233d95bec43a0bd6e0a34ae0a6230813bbdbf1eb
BLAKE2b-256 checksum
How to use checksums
e1a4eab6745280e387badff127ddb003242cb06c0fb5e7515d9924f9811bf5ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.4

Security for flake8-pydantic-fields 0.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page