Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix some code examples #35

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Normaliser(BaseNormaliser):
# if the input file was compressed, the "path" you recieve here will be decompressed

# a temporary file we write 'normalised' data to, that can be easily diffed/compared
normalised = unique_file_in_tempdir(input_filepath=upath, dir=self.tmp_dir)
normalised = unique_file_in_tempdir(input_filepath=path, dir=self.tmp_dir)

# some custom code here per-module that writes to 'normalised'

Expand Down Expand Up @@ -163,14 +163,14 @@ If you're not able to subclass one of the those, you might be able to subclass [
```python
import json
from pathlib import Path
from typing import Iterator
from typing import Iterator, Any

from bleanser.core.modules.extract import ExtractObjectsNormaliser


class Normaliser(ExtractObjectsNormaliser):
def extract_objects(self, path: Path):
data = json.loads(file_path.read_text())
def extract_objects(self, path: Path) -> Iterator[Any]:
data = json.loads(path.read_text())
for blob in data:
yield (blob["id"], blob["href"])

Expand Down
6 changes: 3 additions & 3 deletions src/bleanser/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from glob import glob as do_glob
from pathlib import Path
import os
from typing import Optional, List, Type
from typing import Optional, List, Type, cast

from .common import logger, Dry, Move, Remove, Mode
from .processor import BaseNormaliser, compute_instructions, apply_instructions, bleanser_tmp_directory
Expand Down Expand Up @@ -36,15 +36,15 @@ def call_main() -> None:
def diff(path1: str, path2: Path, *, glob: bool, from_: Optional[int], to: Optional[int], vim: bool, difftool: str) -> None:
path1_: Path
if glob:
assert path2 is _DEFAULT, path2
assert path2 is cast(Path, _DEFAULT), path2
if to is None:
assert from_ is not None
to = from_ + 2
paths = _get_paths(path=path1, from_=from_, to=to, glob=glob)
assert len(paths) == 2, paths
[path1_, path2] = paths
else:
assert path2 is not _DEFAULT
assert cast(str, path2) is not _DEFAULT
path1_ = Path(path1)
path2 = Path(path2)

Expand Down
Loading