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

Fix: Pytest fixtures #355

Merged
merged 4 commits into from
Jul 18, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@

<!-- Maintainers, insert changes / features for the next release here -->

### Development
### Bug fixes

- ci: Fix for tests (#355)
- unihan-etl:

- 0.26.0 -> 0.27.0 (#355)

Fix for pytest fixtures

- unihan-etl: 0.25.0 -> 0.26.0
- 0.25.0 -> 0.26.0

pytest plugin with cached UNIHAN data.

### Development

pytest plugin with cached UNIHAN data.
- ruff: code quality improvements (#354)

## cihai 0.26.0 (2023-07-01)
Expand Down
5 changes: 2 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import sys
import typing as t
from os.path import relpath
from pathlib import Path

import cihai

if t.TYPE_CHECKING:
from sphinx.application import Sphinx

# Get the project root dir, which is the parent dir of this
cwd = Path(__file__).parent
cwd = pathlib.Path(__file__).parent
project_root = cwd.parent
src_root = project_root / "src"

Expand Down Expand Up @@ -250,7 +249,7 @@ def linkcode_resolve(domain: str, info: t.Dict[str, str]) -> t.Union[None, str]:
def remove_tabs_js(app: "Sphinx", exc: Exception) -> None:
# Fix for sphinx-inline-tabs#18
if app.builder.format == "html" and not exc:
tabs_js = Path(app.builder.outdir) / "_static" / "tabs.js"
tabs_js = pathlib.Path(app.builder.outdir) / "_static" / "tabs.js"
tabs_js.unlink(missing_ok=True)


Expand Down
2 changes: 1 addition & 1 deletion examples/variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def run(unihan_options: t.Optional[t.Dict[str, object]] = None) -> None:

c = Cihai(config={"unihan_options": unihan_options})
if not c.unihan.is_bootstrapped: # download and install Unihan to db
c.unihan.bootstrap(unihan_options)
c.unihan.bootstrap()

c.unihan.add_plugin(
"cihai.data.unihan.dataset.UnihanVariants", namespace="variants"
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

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

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ python = "^3.8"
appdirs = "*"
PyYAML = "~6.0"
sqlalchemy = {extras = ["mypy"], version = "~2.0"}
unihan-etl = "~=0.26.0"
unihan-etl = "~=0.27.0"

[tool.poetry.group.dev.dependencies]
### Docs ###
Expand Down
11 changes: 9 additions & 2 deletions src/cihai/data/unihan/bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import dataclasses
import typing as t

import sqlalchemy
Expand All @@ -10,17 +11,23 @@

from .constants import UNIHAN_ETL_DEFAULT_OPTIONS, UNIHAN_FIELDS

if t.TYPE_CHECKING:
from unihan_etl.options import Options as UnihanOptions


def bootstrap_unihan(
engine: sqlalchemy.Engine,
metadata: sqlalchemy.sql.schema.MetaData,
options: t.Optional[t.Dict[str, object]] = None,
options: t.Optional[t.Union[t.Dict[str, object], "UnihanOptions"]] = None,
) -> None:
if options is None:
options = {}

"""Download, extract and import unihan to database."""
options = merge_dict(UNIHAN_ETL_DEFAULT_OPTIONS.copy(), options)
options = merge_dict(
UNIHAN_ETL_DEFAULT_OPTIONS.copy(),
options if isinstance(options, dict) else dataclasses.asdict(options),
)

unihan_pkgr = unihan.Packager(options)
unihan_pkgr.download()
Expand Down