Install & Compatibility
Where this runs
tested against v0.0.20 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.806s · 30.6MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.7s · import 0.726s · 30MB
29MB installed
● package 29MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ConfigModel
✓ from safety_schemas.models import ConfigModel
VulnerabilitySeverityLabels
✓ from safety_schemas.models import VulnerabilitySeverityLabels
Stage
✓ from safety_schemas.models import Stage
Ecosystem
✓ from safety_schemas.models import Ecosystem
This quickstart demonstrates how to import and instantiate a Pydantic model, `VulnerabilitySeverityLabels`, from the `safety_schemas.models` module. It shows basic data assignment, access to model fields, and how Pydantic's validation ensures data integrity upon instantiation.
from safety_schemas.models import VulnerabilitySeverityLabels
# Example of using a Pydantic model from safety-schemas
# This model defines the structure for vulnerability severity labels.
try:
# Instantiate a model instance with valid data
severity_labels = VulnerabilitySeverityLabels(
critical='Critical',
high='High',
medium='Medium',
low='Low',
unknown='Unknown'
)
print(f"Successfully created severity labels: {severity_labels.model_dump_json(indent=2)}")
# Accessing fields
print(f"High severity label: {severity_labels.high}")
# Attempting to create an invalid instance (Pydantic will raise ValidationError)
# Note: Pydantic models are strict by default on extra fields unless configured otherwise
# For demonstration, let's assume valid input for required fields.
except Exception as e:
print(f"Error creating severity labels: {e}")
Debug
Known issues
gotchaOlder versions of `safety-schemas` (e.g., 0.0.1) had strict upper version pins for `packaging` and `pydantic` that could lead to dependency conflicts, especially with newer Python environments (e.g., Python 3.8+ running Pydantic 2.x). This resulted in `safety` CLI being broken on affected Python versions.fixEnsure you are using the latest version of `safety-schemas` (0.0.18 or newer) as dependency pins are often relaxed in later releases. If conflicts persist, explicitly pin `packaging` and `pydantic` to versions compatible with your `safety-schemas` version, or consider using a dedicated virtual environment.
affects: 0.0.1 to potentially other early 0.x.x versions
gotchaThe `safety-schemas` library is primarily an internal dependency of the `safety` CLI tool. While its Pydantic models are importable, it lacks extensive standalone documentation for external usage. Direct programmatic use might require inspecting the `safety` CLI source code for usage patterns.fixRefer to the `safety` CLI's GitHub repository (`pyupio/safety`) to understand how `safety-schemas` models are consumed and integrated within the broader Safety ecosystem. For general Pydantic usage, consult the Pydantic documentation.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'safety_schemas'
The `safety-schemas` library has not been installed in your Python environment or is not accessible on the Python path.
fixpip install safety-schemas
ImportError: cannot import name 'Vulnerability' from 'safety_schemas'
Pydantic models like 'Vulnerability' are located within the `safety_schemas.models` submodule, not directly under the top-level `safety_schemas` package.
fixfrom safety_schemas.models import Vulnerability
pydantic.ValidationError
The data provided to instantiate a `safety-schemas` Pydantic model does not conform to its defined schema, leading to validation failure.
fixfrom safety_schemas.models import Vulnerability
# Ensure all required fields are present and correctly typed
valid_data = {
"package_name": "example-package",
"vulnerability_id": "GHSA-xxxx-xxxx-xxxx",
"analyzed_version": "1.0.0",
"vulnerable_version_range": "<1.0.0",
"published_date": "2023-01-01T00:00:00Z",
"advisory": "A test advisory description."
}
vulnerability_instance = Vulnerability(**valid_data) Upgrade
Version history
0.0.20latest on PyPI · released Aug 20, 2026
Audit
Dependencies
pydanticrequiredProvides the base models for defining schemas.