Parse the given version string and return either a :class:`Version` object or a :class:`LegacyVersion` object depending on if the given version is a valid PEP 440 version or a legacy version.
(version)
| 115 | |
| 116 | |
| 117 | def parse(version): |
| 118 | """ |
| 119 | Parse the given version string and return either a :class:`Version` object |
| 120 | or a :class:`LegacyVersion` object depending on if the given version is |
| 121 | a valid PEP 440 version or a legacy version. |
| 122 | """ |
| 123 | try: |
| 124 | return Version(version) |
| 125 | except InvalidVersion: |
| 126 | return LegacyVersion(version) |
| 127 | |
| 128 | |
| 129 | class InvalidVersion(ValueError): |
nothing calls this directly
no test coverage detected