Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
ci:
skip: [mypy,sourcery]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand All @@ -14,3 +17,17 @@ repos:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
- id: mypy
args: ["--config-file", "pyproject.toml", "--ignore-missing-imports"]
#args: [--strict, --ignore-missing-imports]
- repo: https://github.com/sourcery-ai/sourcery
rev: v1.18.0
hooks:
- id: sourcery
# The best way to use Sourcery in a pre-commit hook:
# * review only changed lines:
# * omit the summary
args: [--diff=git diff HEAD, --no-summary]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ format for easy and efficient use in Python.
</tr>
<tr>
<td>Supported Python Versions</td>
<td><a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20dev-blue?logo=python&logoColor=lightgray"></a></td>
<td><a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue?logo=python&logoColor=lightgray"></a></td>
</tr>
</table>

Expand Down
20 changes: 10 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
requires = [
"defusedxml >=0.7.1",
"pythonbible ==0.10.0",
"pythonbible ==0.13.1",
]
description-file = "README.md"
requires-python = ">=3.8"
Expand All @@ -47,12 +47,7 @@ dev = [
all = [
]

[tool.isort]
profile = "black"
add_imports = "from __future__ import annotations"
force_single_line = true

[tool.ruff]
[tool.ruff.lint]
select = [
"A",
"ANN",
Expand Down Expand Up @@ -100,6 +95,7 @@ select = [
]
ignore = [
"ANN401",
"COM812", # causes conflicts with the formmatter
"D100",
"D101",
"D102",
Expand All @@ -111,15 +107,19 @@ ignore = [
"FBT001",
"FBT002",
"FBT003",
"ISC001", # causes conflicts with the formmatter
]
fix = true

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"pythonbible_parser/osis/old_osis_parser.py" = ["B019", "PLR0913"]
"pythonbible_parser/osis/osis_book_parser.py" = ["C901", "PLR0913"]
"pythonbible_parser/osis/osis_parser.py" = ["PLR0913"]
"tests/*.py" = ["S101"]
"tests/bible_data_test.py" = ["ERA001"]
"tests/conftest.py" = ["E501", "RUF"]
"tests/public_domain_versions_test.py" = ["ERA001"]
# TODO - remove this once code is fully implemented
"pythonbible_parser/usfm/usfm_parser.py" = ["ANN001", "ANN101", "D105", "D107", "T201"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
force-single-line = true
4 changes: 3 additions & 1 deletion pythonbible_parser/bible_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ class BibleParser:
parsers (e.g. OSIS, USFM, USFX, etc.) for parsing scripture text.
"""

version: Version

def __init__(self: BibleParser, version: Version) -> None:
"""Initialize the Bible parser with the version.

:param version:
"""
self.version: Version = version
self.version = version

@abstractmethod
def get_book_title(self: BibleParser, book: Book) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pythonbible_parser/osis/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pythonbible as bible

# noinspection SpellCheckingInspection
BOOK_IDS: dict[bible.Book, str] = MappingProxyType(
BOOK_IDS: MappingProxyType[bible.Book, str] = MappingProxyType(
{
bible.Book.GENESIS: "Gen",
bible.Book.EXODUS: "Exod",
Expand Down
14 changes: 9 additions & 5 deletions pythonbible_parser/osis/old_osis_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

import os
import ast
from functools import lru_cache
from pathlib import Path
from typing import Any
Expand All @@ -25,7 +25,7 @@
from pythonbible_parser.osis.osis_utilities import parse_osis_id
from pythonbible_parser.osis.osis_utilities import strip_namespace_from_tag

XML_FOLDER: str = Path(Path(os.path.realpath(__file__)).parent / "versions")
XML_FOLDER: Path = Path(__file__).parent / "versions"

XPATH_BOOK: str = ".//xmlns:div[@osisID='{}']"
XPATH_BOOK_TITLE: str = f"{XPATH_BOOK}/xmlns:title"
Expand All @@ -51,7 +51,7 @@ def __init__(self: OldOSISParser, version: Version) -> None:
super().__init__(version)

self.tree: ElementTree = ElementTree.parse(
Path(XML_FOLDER / f"{self.version.value.lower()}.xml"),
XML_FOLDER / f"{self.version.value.lower()}.xml",
)
self.namespaces: dict[str, str] = {
"xmlns": get_namespace(self.tree.getroot().tag),
Expand Down Expand Up @@ -103,7 +103,9 @@ def get_scripture_passage_text(
verse_ids_tuple: tuple[int, ...] = tuple(verse_ids)

# keyword arguments
include_verse_number: bool = kwargs.get("include_verse_number", True)
include_verse_number: bool = ast.literal_eval(
str(kwargs.get("include_verse_number", True))
)

return self._get_scripture_passage_text_memoized(
verse_ids_tuple,
Expand Down Expand Up @@ -131,7 +133,9 @@ def verse_text(
raise InvalidVerseError(msg)

# keyword arguments
include_verse_number: bool = kwargs.get("include_verse_number", True)
include_verse_number: bool = ast.literal_eval(
str(kwargs.get("include_verse_number", True))
)

return self._get_verse_text_memoized(verse_id, include_verse_number)

Expand Down
Loading