WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit ef1e2af

Browse files
committed
Refactor to eliminate Mapping subclass
1 parent 50ecd1f commit ef1e2af

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

fgpyo/sequence.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
ex. https://pypi.org/project/Distance/
1010
"""
1111

12-
from collections.abc import Iterator
1312
from collections.abc import Mapping
1413
from typing import Dict
1514
from typing import List
@@ -58,8 +57,8 @@
5857
}
5958

6059

61-
class ComplementsTable(Mapping[int, int]):
62-
"""Implements Mapping from int to int, but raises ValueError if a bad key is checked.
60+
class ComplementsTable:
61+
"""Contains a Mapping from int to int, but raises ValueError if a bad key is checked.
6362
6463
This table can be used with str.translate to form base complements faster than directly using
6564
the input Mapping in an iterator. Raising ValueError on a bad .get allows for catching errors
@@ -80,14 +79,6 @@ def __getitem__(self, item: int) -> int:
8079
except KeyError as key_error:
8180
raise ValueError(f"Invalid base: {chr(item)}") from key_error
8281

83-
def __len__(self) -> int:
84-
"""Get length, required for Mapping derived class."""
85-
return len(self._mapping)
86-
87-
def __iter__(self) -> Iterator[int]:
88-
"""Get iterator, required for Mapping derived class."""
89-
return iter(self._mapping)
90-
9182

9283
_COMPLEMENTS_TABLE: ComplementsTable = ComplementsTable(_COMPLEMENTS)
9384
"""Encode _Complements for faster complement lookup via str.translate."""

0 commit comments

Comments
 (0)