From fa1f57d38d29f43a51cec5dd9c079815c2196f4d Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Wed, 8 May 2024 20:37:36 -0400 Subject: [PATCH] chore: Use warnings.warn(..., category=...) style --- ocdskit/combine.py | 10 ++++++++-- ocdskit/packager.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ocdskit/combine.py b/ocdskit/combine.py index d815115..0270475 100644 --- a/ocdskit/combine.py +++ b/ocdskit/combine.py @@ -88,7 +88,10 @@ def combine_record_packages(packages, uri='', publisher=None, published_date='', if 'records' in package: output['records'].extend(package['records']) else: - warnings.warn(f'item {i} has no "records" field (check that it is a record package)') + warnings.warn( + f'item {i} has no "records" field (check that it is a record package)', + category=MissingRecordsWarning, + ) if 'packages' in package: output['packages'].update(dict.fromkeys(package['packages'])) @@ -122,7 +125,10 @@ def combine_release_packages(packages, uri='', publisher=None, published_date='' if 'releases' in package: output['releases'].extend(package['releases']) else: - warnings.warn(f'item {i} has no "releases" field (check that it is a release package)') + warnings.warn( + f'item {i} has no "releases" field (check that it is a release package)', + category=MissingReleasesWarning, + ) if publisher: output['publisher'] = publisher diff --git a/ocdskit/packager.py b/ocdskit/packager.py index ced1d99..54993cf 100644 --- a/ocdskit/packager.py +++ b/ocdskit/packager.py @@ -195,7 +195,7 @@ def output_records( record['versionedRelease'] = merger.create_versioned_release(releases) except InconsistentTypeError as e: if convert_exceptions_to_warnings: - warnings.warn(MergeErrorWarning(str(e))) + warnings.warn(str(e), category=MergeErrorWarning) else: raise