Skip to content

Commit

Permalink
Update black and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
titusz committed Oct 19, 2024
1 parent 104ee7a commit c382ddc
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 41 deletions.
2 changes: 1 addition & 1 deletion iscc_core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def type_id(self) -> str:
length = "".join([t.name[0] for t in mtypes]) + "DI"
else:
length = self.length
return f"{self.maintype.name}-" f"{self.subtype.name}-" f"{self.version.name}-" f"{length}"
return f"{self.maintype.name}-{self.subtype.name}-{self.version.name}-{length}"

@property
def explain(self) -> str:
Expand Down
79 changes: 53 additions & 26 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ pytest-cov = "*"

[tool.poetry.group.dev.dependencies]
poethepoet = "*"
black = "^23.1"
bandit = "^1.7"
black = "*"
ruff = "*"
bandit = "*"

[tool.poetry.group.docs.dependencies]
mkdocs-material = "^9.0"
Expand All @@ -78,9 +79,10 @@ mdformat_tables = "*"
griffe = "<0.27.4"

[tool.black]
skip-string-normalization = false
line-length = 100
target-version = ['py37']
preview = true
enable-unstable-feature = ["string_processing"]
target-version = ['py39']

[tool.poe.tasks]
gentests = { cmd = "poetry run python -m tests.build_test_data", help = "Generate conformance test data" }
Expand Down
16 changes: 13 additions & 3 deletions tests/build_docs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Copy README.md to documentation index.md"""

from os.path import abspath, dirname, join


Expand All @@ -13,9 +14,18 @@ def main():
"""Copy root files to documentation site."""
with open(SRC, "rt", encoding="utf-8") as infile:
text = infile.read()
m = "![ISCC Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png)\n"
r1 = "![ISCC Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png#only-light)\n"
r2 = "![ISCC Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-dark.png#only-dark)\n"
m = (
"![ISCC"
" Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png)\n"
)
r1 = (
"![ISCC"
" Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-light.png#only-light)\n"
)
r2 = (
"![ISCC"
" Architecture](https://raw.githubusercontent.com/iscc/iscc-core/master/docs/images/iscc-codec-dark.png#only-dark)\n"
)
text = text.replace(m, r1 + r2)
with open(DST, "wt", encoding="utf-8", newline="\n") as outf:
outf.write(text)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_code_content_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_code_text_c_256_bits():


def test_normalize_text():
txt = " Iñtërnâtiôn\nàlizætiøn☃💩 – is a tric\t ky \u00A0 thing!\r"
txt = " Iñtërnâtiôn\nàlizætiøn☃💩 – is a tric\t ky \u00a0 thing!\r"

normalized = iscc_core.code_content_text.text_collapse(txt)
assert normalized == "internationalizætiøn☃💩isatrickything"
Expand Down
5 changes: 3 additions & 2 deletions tests/test_code_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ def test_clean_text_markdowsn():
More Text
"""

assert ic.text_clean(text) == (
"# Document\n"
assert (
ic.text_clean(text)
== "# Document\n"
"\n"
"*Subtitle*\n"
"\n"
Expand Down
10 changes: 6 additions & 4 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,13 @@ def test_hamming_distance_raises():


def test_multi_hash_blake3():
assert ic.multi_hash_blake3(b"") == (
"1e20af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"
assert (
ic.multi_hash_blake3(b"")
== "1e20af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262"
)
assert ic.multi_hash_blake3(b"hello world") == (
"1e20d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24"
assert (
ic.multi_hash_blake3(b"hello world")
== "1e20d74981efa70a0c880b8d8c1985d075dbcbf679b99a5f9914e5aaf96b831a9e24"
)


Expand Down
1 change: 1 addition & 0 deletions tools/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Inspect full iscc_core api"""

import inspect
from pprint import pprint
import iscc_core
Expand Down
1 change: 1 addition & 0 deletions tools/lf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Convert line endings to LF"""

import pathlib

HERE = pathlib.Path(__file__).parent.parent.absolute()
Expand Down

0 comments on commit c382ddc

Please sign in to comment.