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

Fix some mistaken type signatures #25

Merged
merged 1 commit into from
May 9, 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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

## Unreleased changes

- Fix some incorrect type signatures.
We were mistakenly asking for `django.db.models.Model` instead of `type[django_db.models.Model]` in:
- `django_integrity.constraints.foreign_key_constraint_name`
- `django_integrity.conversion.Unique`
- `django_integrity.conversion.PrimaryKey`
- `django_integrity.conversion.NotNull`
- `django_integrity.conversion.ForeignKey`

## v0.1.0 - 2024-05-07

- Initial release! WOO!
Expand Down
2 changes: 1 addition & 1 deletion src/django_integrity/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class NotInTransaction(Exception):


def foreign_key_constraint_name(
model: django_db.models.Model, field_name: str, *, using: str
model: type[django_db.models.Model], field_name: str, *, using: str
) -> str:
"""
Calculate FK constraint name for a model's field.
Expand Down
8 changes: 4 additions & 4 deletions src/django_integrity/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Unique(_Rule):
A unique constraint defined by a model and a set of fields.
"""

model: django_db.models.Model
model: type[django_db.models.Model]
fields: tuple[str]

_pattern = re.compile(r"Key \((?P<fields>.+)\)=\(.*\) already exists.")
Expand Down Expand Up @@ -102,7 +102,7 @@ class PrimaryKey(_Rule):
trying to create a PrimaryKey rule.
"""

model: django_db.models.Model
model: type[django_db.models.Model]

_pattern = re.compile(r"Key \((?P<fields>.+)\)=\(.*\) already exists.")

Expand Down Expand Up @@ -149,7 +149,7 @@ class NotNull(_Rule):
A not-null constraint on a Model's field.
"""

model: django_db.models.Model
model: type[django_db.models.Model]
field: str

def is_match(self, error: django_db.IntegrityError) -> bool:
Expand All @@ -168,7 +168,7 @@ class ForeignKey(_Rule):
A foreign key constraint on a Model's field.
"""

model: django_db.models.Model
model: type[django_db.models.Model]
field: str

_detail_pattern = re.compile(
Expand Down