Browse Source

Add docstrings to packaging.tags.Tag and packaging.tags.parse_tag() (#281)

Closes #278

Co-authored-by: Derek Keeler <derek.keeler@gmail.com>
pull/284/head
Derek Keeler 2 years ago committed by GitHub
parent
commit
d3f305de93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .gitignore
  2. 14
      packaging/tags.py

1
.gitignore vendored

@ -7,6 +7,7 @@
.coverage
.idea
.venv*
.vscode/
.mypy_cache/
.pytest_cache/

14
packaging/tags.py

@ -58,6 +58,12 @@ _32_BIT_INTERPRETER = sys.maxsize <= 2 ** 32
class Tag(object):
"""
A representation of the tag triple for a wheel.
Instances are considered immutable and thus are hashable. Equality checking
is also supported.
"""
__slots__ = ["_interpreter", "_abi", "_platform"]
@ -108,6 +114,12 @@ class Tag(object):
def parse_tag(tag):
# type: (str) -> FrozenSet[Tag]
"""
Parses the provided tag (e.g. `py3-none-any`) into a frozenset of Tag instances.
Returning a set is required due to the possibility that the tag is a
compressed tag set.
"""
tags = set()
interpreters, abis, platforms = tag.split("-")
for interpreter in interpreters.split("."):
@ -541,7 +553,7 @@ class _ELFFileHeader(object):
def unpack(fmt):
# type: (str) -> int
try:
result, = struct.unpack(
(result,) = struct.unpack(
fmt, file.read(struct.calcsize(fmt))
) # type: (int, )
except struct.error:

Loading…
Cancel
Save