Skip to content

Commit

Permalink
chore: Use warnings.warn(..., category=...) style
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed May 9, 2024
1 parent 85e7e6b commit fa1f57d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions ocdskit/combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']))

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ocdskit/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fa1f57d

Please sign in to comment.