diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2014-12-18 08:21:51 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2014-12-18 08:21:51 -0500 |
| commit | 20ac482786bc7622f67df8ab13810fde9fd850ac (patch) | |
| tree | 8c32697bda4c212a78d352fde152d786c00c6c91 | |
| parent | 4bf1bfade0e23f74667989932f3c80c1252a64ef (diff) | |
| parent | 6d98caab2c4103cba53e6c601fc127990298ab56 (diff) | |
| download | python-setuptools-git-20ac482786bc7622f67df8ab13810fde9fd850ac.tar.gz | |
Merge pull request #20 from dstufft/dont-warn-empty
Don't warn on empty non PEP 440 versions
| -rw-r--r-- | pkg_resources.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/pkg_resources.py b/pkg_resources.py index 5af4c869..f3ac6c50 100644 --- a/pkg_resources.py +++ b/pkg_resources.py @@ -2415,15 +2415,23 @@ class Distribution(object): self._parsed_version = parse_version(self.version) if isinstance( self._parsed_version, packaging.version.LegacyVersion): - warnings.warn( - "'%s (%s)' is being parsed as a legacy, non PEP 440, " - "version. You may find odd behavior and sort order. In " - "particular it will be sorted as less than 0.0. It is " - "recommend to migrate to PEP 440 compatible versions." % ( - self.project_name, self.version, - ), - RuntimeWarning, - ) + # While an empty version is techincally a legacy version and + # is not a valid PEP 440 version, it's also unlikely to + # actually come from someone and instead it is more likely that + # it comes from setuptools attempting to parse a filename and + # including it in the list. So for that we'll gate this warning + # on if the version is anything at all or not. + if self.version: + warnings.warn( + "'%s (%s)' is being parsed as a legacy, non PEP 440, " + "version. You may find odd behavior and sort order. " + "In particular it will be sorted as less than 0.0. It " + "is recommend to migrate to PEP 440 compatible " + "versions." % ( + self.project_name, self.version, + ), + RuntimeWarning, + ) return self._parsed_version |
