Skip to content

Commit

Permalink
Use typing.TextIO in typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed Jun 12, 2023
1 parent 039d277 commit 3386294
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions minigrep_py/search.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Standard Library
import re
from dataclasses import dataclass
from io import TextIOBase
from typing import Self
from typing import Self, TextIO


@dataclass
Expand All @@ -11,7 +10,7 @@ class SearchConfig:
input: str

@classmethod
def new(cls, patterns: list[str], input: TextIOBase) -> Self:
def new(cls, patterns: list[str], input: TextIO) -> Self:
pats = [re.compile(pat) for pat in patterns]
return cls(pats, input.read())

Expand All @@ -32,5 +31,5 @@ def run(self) -> list[str]:
]

@classmethod
def new(cls, patterns: list[str], input: TextIOBase) -> Self:
def new(cls, patterns: list[str], input: TextIO) -> Self:
return cls(cls.Config.new(patterns, input))

0 comments on commit 3386294

Please sign in to comment.