Skip to content

Commit

Permalink
fix: types
Browse files Browse the repository at this point in the history
  • Loading branch information
15r10nk committed Oct 21, 2024
1 parent ed28cd7 commit 1023de5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/inline_snapshot/_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from asttokens.util import Token
from executing.executing import EnhancedAST
from executing.executing import Source
from inline_snapshot._source_file import SourceFile

from ._rewrite_code import ChangeRecorder
Expand Down Expand Up @@ -101,7 +100,7 @@ def brace_tokens(source, node) -> TokenRange:


def generic_sequence_update(
source: Source,
source: SourceFile,
parent: Union[ast.List, ast.Tuple, ast.Dict, ast.Call],
brace_tokens: TokenRange,
parent_elements: List[Union[TokenRange, None]],
Expand Down Expand Up @@ -166,7 +165,7 @@ def apply_all(all_changes: List[Change]):
by_parent: Dict[
EnhancedAST, List[Union[Delete, DictInsert, ListInsert, CallArg]]
] = defaultdict(list)
sources: Dict[EnhancedAST, Source] = {}
sources: Dict[EnhancedAST, SourceFile] = {}

for change in all_changes:
if isinstance(change, Delete):
Expand Down
2 changes: 1 addition & 1 deletion src/inline_snapshot/_rewrite_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _replace(self, filename, range, new_contend):


class SourceFile:
def __init__(self, filename):
def __init__(self, filename: pathlib.Path):
self.replacements: list[Replacement] = []
self.filename = filename
self.source = self.filename.read_text("utf-8")
Expand Down
2 changes: 2 additions & 0 deletions src/inline_snapshot/_source_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import tokenize
from pathlib import Path

from executing import Source
from inline_snapshot._format import format_code
from inline_snapshot._unmanaged import is_dirty_equal
from inline_snapshot._utils import normalize
Expand All @@ -11,6 +12,7 @@


class SourceFile:
_source = Source

def __init__(self, source):
if isinstance(source, SourceFile):
Expand Down
2 changes: 1 addition & 1 deletion src/inline_snapshot/_unmanaged.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def is_dirty_equal(value):


def update_allowed(value):
return not (is_dirty_equal(value) or isinstance(value, (Is, Snapshot)))
return not (is_dirty_equal(value) or isinstance(value, (Is, Snapshot))) # type: ignore


def is_unmanaged(value):
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from inline_snapshot._format import format_code
from inline_snapshot._inline_snapshot import Flags
from inline_snapshot._rewrite_code import ChangeRecorder
from inline_snapshot._types import Category
from inline_snapshot.testing._example import snapshot_env

pytest_plugins = "pytester"
Expand Down Expand Up @@ -53,7 +54,7 @@ def w(source_code, *, flags="", reported_flags=None, number=1):


@pytest.fixture()
def source(tmp_path):
def source(tmp_path: Path):
filecount = 1

@dataclass
Expand All @@ -64,8 +65,8 @@ class Source:
number_snapshots: int = 0
number_changes: int = 0

def run(self, *flags):
flags = Flags({*flags})
def run(self, *flags_arg: Category):
flags = Flags({*flags_arg})

nonlocal filecount
filename: Path = tmp_path / f"test_{filecount}.py"
Expand Down

0 comments on commit 1023de5

Please sign in to comment.