diff --git a/fgpyo/fasta/sequence_dictionary.py b/fgpyo/fasta/sequence_dictionary.py index 2ed9e54..0729ea3 100644 --- a/fgpyo/fasta/sequence_dictionary.py +++ b/fgpyo/fasta/sequence_dictionary.py @@ -498,13 +498,6 @@ def from_sam( return seq_dict - # TODO: mypy doesn't like these - # @overload - # def __getitem__(self, key: str) -> SequenceMetadata: ... - # - # @overload - # def __getitem__(self, index: int) -> SequenceMetadata: ... - def __getitem__(self, key: Union[str, int]) -> SequenceMetadata: return self._dict[key] if isinstance(key, str) else self.infos[key] diff --git a/tests/fgpyo/fasta/test_sequence_dictionary.py b/tests/fgpyo/fasta/test_sequence_dictionary.py index 22fb1b6..a5037af 100644 --- a/tests/fgpyo/fasta/test_sequence_dictionary.py +++ b/tests/fgpyo/fasta/test_sequence_dictionary.py @@ -333,9 +333,9 @@ def test_sequence_dictionary_to_and_from_sam() -> None: header_dict={"HD": {"VN": "1.5"}, "SQ": mapping, "RG": [{"ID": "foo"}]} ) samfile: Path = builder.SamBuilder(sd=mapping).to_path() - alignment: pysam.AlignmentFile = reader(samfile) + with reader(samfile) as alignment_fh: # pysam.AlignmentFile + assert SequenceDictionary.from_sam(alignment_fh) == sd assert SequenceDictionary.from_sam(samfile) == sd - assert SequenceDictionary.from_sam(alignment) == sd assert SequenceDictionary.from_sam(mapping) == sd assert SequenceDictionary.from_sam(header) == sd assert sd.to_sam_header(extra_header={"RG": [{"ID": "foo"}]})