Skip to content

Commit 871458e

Browse files
committed
Clarify that the Headers class is a Sequence
This is both in the docs (via the changelog) and by inheriting from the Sequence ABC. As the Sequence ABC has a __iter__ method another is not required.
1 parent 82d5e46 commit 871458e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

h11/_headers.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
from collections.abc import Sequence
23

34
from ._abnf import field_name, field_value
45
from ._util import bytesify, LocalProtocolError, validate
@@ -62,7 +63,7 @@
6263
_field_value_re = re.compile(field_value.encode("ascii"))
6364

6465

65-
class Headers:
66+
class Headers(Sequence):
6667
"""
6768
A list-like interface that allows iterating over headers as byte-pairs
6869
of (lowercased-name, value).
@@ -92,10 +93,6 @@ class Headers:
9293
def __init__(self, full_items):
9394
self._full_items = full_items
9495

95-
def __iter__(self):
96-
for _, name, value in self._full_items:
97-
yield name, value
98-
9996
def __bool__(self):
10097
return bool(self._full_items)
10198

newsfragments/112.doc.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Clarify that the Headers class is a Sequence and inherit from the
2+
collections Sequence abstract base class to also indicate this (and
3+
gain the mixin methods). See also #104.

0 commit comments

Comments
 (0)