Avoid DeprecationWarning: Implicit None on return values is deprecated and will raise KeyErrors

The warning only happened on corrupted metadata.

The warning originates in 880a6219a1
This commit is contained in:
Miro Hrončok 2023-10-03 12:07:49 +02:00
parent 8fe27ad070
commit 52372a464c
2 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,7 @@
Name: python-rpm-generators
Summary: Dependency generators for Python RPMs
Version: 14
Release: 7%{?dist}
Release: 8%{?dist}
Url: https://src.fedoraproject.org/rpms/python-rpm-generators
@ -56,6 +56,9 @@ install -Dpm0755 -t %{buildroot}%{_rpmconfigdir} *.py
%{_rpmconfigdir}/pythonbundles.py
%changelog
* Tue Oct 03 2023 Miro Hrončok <mhroncok@redhat.com> - 14-8
- Avoid DeprecationWarning: Implicit None on return values is deprecated and will raise KeyErrors
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 14-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

View File

@ -94,8 +94,8 @@ class Distribution(PathDistribution):
# that it works also on previous Python/importlib_metadata versions.
@property
def name(self):
"""Return the 'Name' metadata for the distribution package."""
return self.metadata['Name']
"""Return the 'Name' metadata for the distribution package or None."""
return self.metadata.get('Name')
def _parse_py_version(self, path):
# Try to parse the Python version from the path the metadata