Skip to content

Commit

Permalink
Support 3.13 and migrate uv from PDM
Browse files Browse the repository at this point in the history
  • Loading branch information
tasuren committed Oct 13, 2024
1 parent 00a5b6e commit 81be6ac
Show file tree
Hide file tree
Showing 16 changed files with 630 additions and 553 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,6 @@ cython_debug/

# macOS
.DS_Store

# Development
.python-version
6 changes: 3 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"recommendations": [
"ms-python.black-formatter",
"ms-python.vscode-pylanc"
"charliermarsh.ruff",
"ms-python.python"
]
}
}
6 changes: 0 additions & 6 deletions CONTRIBUTING.md

This file was deleted.

16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
[![PyPI](https://img.shields.io/pypi/v/i21y)](https://pypi.org/project/i21y/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/i21y) ![PyPI - Downloads](https://img.shields.io/pypi/dm/i21y) ![PyPI - License](https://img.shields.io/pypi/l/i21y) [![Documentation Status](https://readthedocs.org/projects/i21y/badge/?version=latest)](https://i21y.readthedocs.io/en/latest/?badge=latest) [![Buy Me a Coffee](https://img.shields.io/badge/-tasuren-E9EEF3?label=Buy%20Me%20a%20Coffee&logo=buymeacoffee)](https://www.buymeacoffee.com/tasuren)
[![PyPI](https://img.shields.io/pypi/v/i21y)](https://pypi.org/project/i21y/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/i21y)
![PyPI - Downloads](https://img.shields.io/pypi/dm/i21y)
![PyPI - License](https://img.shields.io/pypi/l/i21y)
[![Documentation Status](https://readthedocs.org/projects/i21y/badge/?version=latest)](https://i21y.readthedocs.io/en/latest/?badge=latest)
[![Buy Me a Coffee](https://img.shields.io/badge/-tasuren-E9EEF3?label=Buy%20Me%20a%20Coffee&logo=buymeacoffee)](https://www.buymeacoffee.com/tasuren)

# i21y
i21y (a.k.a internationalization.py) is library for support i18n in Python. It is easy to use.

**Features:**
- Zero dependencies by default
- Simple design
- Tools to Simplify Keys
- Utilities to simplify keys

## Installation
Normal: `pip install i21y`
Expand Down Expand Up @@ -36,5 +42,7 @@ assert t(LONG_KEY + "but_easy_to_use", locale="ja") == "とても長いキーで
## Documentation
See the [documentation](https://i21y.readthedocs.io/) for usage and details.

## License
i21y is licensed under the [MIT license](./LICENSE).
## Contributing Guide
This project is managed by the package manager PDM.
In coding, please use Black as a code formatter and pyright for type checking. The configuration is described in `pyproject.toml`.
Please write what you have done in a complete sentence and use the original form of the verb. e.g. `Fix that locale_str can't join`.
490 changes: 0 additions & 490 deletions pdm.lock

This file was deleted.

59 changes: 30 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,53 @@
name = "i21y"
description = "The simple library for i18n support."
authors = [
{name = "Takagi Tasuku", email = "[email protected]"},
{ name = "Takagi Tasuku", email = "[email protected]" },
]
dependencies = []
requires-python = ">=3.11"
readme = "README.md"
license = {file = "LICENSE"}
license = { file = "LICENSE" }
keywords = ["i18n"]
classifiers = [
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Internationalization",
"Typing :: Typed"
]
include = ["i21y/py.typed"]
requires-python = ">=3.11"
dependencies = []
dynamic = ["version"]

[tool.pdm]
version = {source = "file", path = "src/i21y/__init__.py"}
[project.optional-dependencies]
yaml = ["pyyaml~=6.0"]
fast_json = ["orjson~=3.10"]

[tool.uv]
dev-dependencies = [
"myst-parser>=4.0.0",
"pytest>=8.3.3",
"sphinx>=8.1.2",
"sphinx-intl>=2.2.0",
"ruff>=0.6.9",
]

[project.urls]
Source = "https://github.com/tasuren/i21y"
Documentation = "https://i21y.readthedocs.io/"
Donate = "https://www.buymeacoffee.com/tasuren"
Chat = "https://discord.gg/kfMwZUyGFG"

[optional-dependencies]
yaml = ["pyyaml~=6.0"]
fast_json = ["orjson~=3.8.6"]

[tool.pdm.dev-dependencies]
test = [
"pytest~=7.1.2",
"pyyaml~=6.0",
"orjson~=3.8.6"
]
doc = [
"sphinx",
"sphinx-intl",
"myst-parser"
]
[tool.pytest.ini_options]
addopts = ["--import-mode=importlib"]
testpaths = ["tests"]

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.version]
path = "src/i21y/__init__.py"

[tool.pyright]
typingCheckMode = "basic"
[tool.hatch.metadata]
allow-direct-references = true

[tool.black]
target-version = ['py311']
[tool.hatch.build.targets.wheel]
packages = ["src/i21y"]
4 changes: 2 additions & 2 deletions src/i21y/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__author__ = "Takagi Tasuku"
__version__ = "0.2.0"
__version__ = "0.3.0"
__all__ = ("Translator", "I21YError", "TranslationNotFound", "locale_str")

from .translator import Translator
from .error import I21YError, TranslationNotFound
from .translator import Translator
from .utils import locale_str
8 changes: 4 additions & 4 deletions src/i21y/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def search_impl(
@overload
def search(
self, locale: str, key: str, default: type[Undefined] = Undefined
) -> str:
...
) -> str: ...

@overload
def search(self, locale: str, key: str, default: SearchT = Undefined) -> SearchT:
...
def search(
self, locale: str, key: str, default: SearchT = Undefined
) -> SearchT: ...

def search(
self, locale: str, key: str, default: SearchT | type[Undefined] = Undefined
Expand Down
5 changes: 3 additions & 2 deletions src/i21y/loaders/file_.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ class LocaleFile:

def __init__(self, parent: Loader, locale: str, path: PurePath) -> None:
self.parent, self.path, self.data = parent, path, DataDict()
self.locale, self.key = locale, ".".join(
self.path.parts[parent.path_size + 1 : -1] + (self.path.stem,)
self.locale, self.key = (
locale,
".".join(self.path.parts[parent.path_size + 1 : -1] + (self.path.stem,)),
)

def get(self, key: str | Iterable[str]) -> str | None:
Expand Down
3 changes: 2 additions & 1 deletion src/i21y/loaders/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from pathlib import PurePath

from .file_ import Loader as FileLoader, LocaleFile
from .file_ import Loader as FileLoader
from .file_ import LocaleFile

try:
from orjson import loads
Expand Down
3 changes: 2 additions & 1 deletion src/i21y/loaders/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
% e
)

from .file_ import Loader as FileLoader, LocaleFile
from .file_ import Loader as FileLoader
from .file_ import LocaleFile


class Loader(FileLoader):
Expand Down
6 changes: 2 additions & 4 deletions src/i21y/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@ def join_raw(self, *other: str | locale_str) -> str:
@overload
def join(
self: ..., *other: str | locale_str, cls: type[AdtnlClsT], **extras: Any
) -> AdtnlClsT:
...
) -> AdtnlClsT: ...

@overload
def join(
self: SelfT, *other: str | locale_str, cls: None = None, **extras: Any
) -> SelfT:
...
) -> SelfT: ...

def join(
self: SelfT,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_general.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from src.i21y import Translator
from src.i21y.loaders.json import Loader
from i21y import Translator
from i21y.loaders.json import Loader


def do_test_translator(t: Translator[Loader]) -> None:
assert t("general.main") == "main"
assert t("general.main", locale="ja") == "メイン"

from src.i21y.utils import locale_str
from i21y.utils import locale_str

BASE = locale_str("wow.a")
assert t(BASE.b) == "Layor B"
Expand Down
3 changes: 1 addition & 2 deletions tests/test_locale_str.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from src.i21y import locale_str

from i21y import locale_str

BASE = locale_str("aiueo")
assert str(BASE) == "aiueo" and BASE.key == "aiueo"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_yaml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from src.i21y import Translator
from src.i21y.loaders.yaml import Loader
from i21y import Translator
from i21y.loaders.yaml import Loader


def do_test_translator(t: Translator[Loader]) -> None:
Expand Down
Loading

0 comments on commit 81be6ac

Please sign in to comment.