Skip to content
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: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
# E124: closing bracket does not match visual indentation
# E126: over-indentation
# E501: line too long
# BLK100: black formattable
ignore = E124,E126,E501,BLK100
indent-size = 2
exclude = .venv,build,dist
4 changes: 0 additions & 4 deletions MANIFEST.in

This file was deleted.

18 changes: 11 additions & 7 deletions budoux/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@
import sys
import textwrap
import typing
from pathlib import Path

# TODO: replace with importlib.resources when py3.8 support is dropped.
import importlib_resources
from importlib import resources

import budoux

ArgList = typing.Optional[typing.List[str]]
models: Path = importlib_resources.files('budoux') / "models"
langs = dict((model.stem, model) for model in models.glob("*.json"))
# Using typing.Any for resource related objects to avoid complex conditional
# imports for Traversable which varies across Python versions.
models: typing.Any = resources.files('budoux') / "models"
langs: typing.Dict[str, typing.Any] = {
model.name[:-5]: model
for model in models.iterdir()
if model.name.endswith(".json")
}


class BudouxHelpFormatter(argparse.ArgumentDefaultsHelpFormatter,
Expand All @@ -55,7 +58,7 @@ def check_file(path: str) -> str:
raise argparse.ArgumentTypeError(f"'{path}' is not found.")


def check_lang(lang: str) -> Path:
def check_lang(lang: str) -> typing.Any:
"""Check if given language exists or not.

Args:
Expand Down Expand Up @@ -153,6 +156,7 @@ def parse_args(test: ArgList = None) -> argparse.Namespace:
def _main(test: ArgList = None) -> str:
args = parse_args(test=test)
model_path = args.lang or args.model
# Using open() directly assuming model_path is a path-like object.
with open(model_path, 'r', encoding='utf-8') as f:
model = json.load(f)

Expand Down
80 changes: 79 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,81 @@
[build-system]
requires = ["wheel", "setuptools"]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "budoux"
dynamic = ["version"]
description = "BudouX is the successor of Budou"
readme = "README.md"
license = {text = "Apache-2.0"}
authors = [
{name = "Shuhei Iitsuka", email = "tushuhei@google.com"},
]
classifiers = [
"Development Status :: 3 - Alpha",
"Operating System :: OS Independent",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.10"
dependencies = []

[project.optional-dependencies]
jaxcpu = [
"jax>=0.9.0",
]
dev = [
"build",
"flake8",
"isort",
"mypy>=1.0.0",
"pytest",
"regex",
"toml",
"twine",
"types-regex",
"types-setuptools",
"yapf",
]

[project.scripts]
budoux = "budoux.main:main"

[tool.setuptools.dynamic]
version = {attr = "budoux.__init__.__version__"}

[tool.setuptools.packages.find]
where = ["."]
include = ["budoux*"]

[tool.setuptools.package-data]
budoux = ["models/*.json", "skip_nodes.json", "py.typed"]

[dependency-groups]
dev = [
"build",
"flake8",
"isort",
"mypy>=1.0.0",
"pytest",
"regex",
"toml",
"twine",
"types-regex",
"types-setuptools",
"yapf",
"jax>=0.9.0",
]

[tool.yapf]
based_on_style = "yapf"


[tool.mypy]
python_version = "3.10"
pretty = true
strict = true
allow_untyped_calls = true
63 changes: 0 additions & 63 deletions setup.cfg

This file was deleted.

17 changes: 0 additions & 17 deletions setup.py

This file was deleted.

Loading
Loading