Skip to content

Commit

Permalink
Remove backward compatible import from contrib.django.models
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <tdruez@nexb.com>
  • Loading branch information
tdruez committed Apr 10, 2023
1 parent 8b2678f commit d8a3235
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

unreleased
----------

- Remove deprecated `purl_to_lookups` and `without_empty_values` import compatibility
from `packageurl.contrib.django.models`.
Replace those functions import using `packageurl.contrib.django.utils`.

0.11.1 (2022-03-24)
-------------------

Expand Down
25 changes: 2 additions & 23 deletions src/packageurl/contrib/django/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,12 @@
# Visit https://github.com/package-url/packageurl-python for support and
# download.

import warnings

from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _

from packageurl import PackageURL
from packageurl.contrib.django.utils import purl_to_lookups as _purl_to_lookups
from packageurl.contrib.django.utils import without_empty_values as _without_empty_values


def purl_to_lookups(purl, encode=True):
warnings.warn(
"purl_to_lookups is deprecated and will be removed in a future version. "
"Use packageurl.contrib.django.utils.purl_to_lookups instead.",
DeprecationWarning,
)
return _purl_to_lookups(purl_str=purl, encode=encode)


def without_empty_values(input_dict):
warnings.warn(
"without_empty_values is deprecated and will be removed in a future version. "
"Use packageurl.contrib.django.utils.without_empty_values instead.",
DeprecationWarning,
)
return _without_empty_values(input_dict)
from packageurl.contrib.django.utils import purl_to_lookups


class PackageURLQuerySetMixin:
Expand All @@ -63,7 +42,7 @@ def for_package_url(self, purl_str, encode=True):
Filter the QuerySet with the provided Package URL string.
The purl string is validated and transformed into filtering lookups.
"""
lookups = purl_to_lookups(purl=purl_str, encode=encode)
lookups = purl_to_lookups(purl_str=purl_str, encode=encode)
if lookups:
return self.filter(**lookups)
return self.none()
Expand Down

0 comments on commit d8a3235

Please sign in to comment.