Skip to content

Commit a6c3d02

Browse files
committed
Merge branch 'main' into fix-error-code
2 parents fd61d07 + f73bf88 commit a6c3d02

33 files changed

Lines changed: 789 additions & 370 deletions

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
2-
exclude=.tox
2+
exclude=.venv
33
extend-ignore = E203
44
max-line-length=120

.github/workflows/ci.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,38 @@ on:
55
branches:
66
- main
77
pull_request:
8+
workflow_dispatch:
89

910
jobs:
1011
lint:
1112
runs-on: ubuntu-latest
1213
steps:
13-
- uses: actions/checkout@v4
14-
- uses: actions/setup-python@v5
14+
- uses: actions/checkout@v6
15+
- uses: astral-sh/setup-uv@v7
1516
with:
16-
cache: pip
17-
cache-dependency-path: |
18-
dev-requirements.txt
19-
fluent.syntax/setup.py
20-
fluent.runtime/setup.py
21-
- run: python -m pip install -r dev-requirements.txt
22-
- run: python -m pip install ./fluent.syntax ./fluent.runtime
23-
- run: python -m flake8
24-
- run: python -m mypy fluent.syntax/fluent fluent.runtime/fluent
17+
python-version: 3.9
18+
- uses: actions/setup-python@v6
19+
- run: uv sync --dev --all-packages
20+
- run: uv run python -m flake8
21+
- run: uv run mypy fluent.syntax/fluent fluent.runtime/fluent
2522
test:
2623
runs-on: ${{ matrix.os }}
2724
strategy:
2825
matrix:
29-
os: [ubuntu-22.04, windows-2022]
30-
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, 3.12, pypy3.9, pypy3.10]
26+
os: [ubuntu-latest, windows-latest, macos-latest]
27+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
3128
steps:
32-
- uses: actions/checkout@v4
33-
- uses: actions/setup-python@v5
29+
- uses: actions/checkout@v6
30+
- uses: astral-sh/setup-uv@v7
3431
with:
3532
python-version: ${{ matrix.python-version }}
36-
cache: pip
37-
cache-dependency-path: |
38-
fluent.syntax/setup.py
39-
fluent.runtime/setup.py
40-
- run: python -m pip install ./fluent.syntax ./fluent.runtime
41-
- run: python -m unittest discover -s fluent.syntax
42-
- run: python -m unittest discover -s fluent.runtime
33+
- run: uv sync --dev --all-packages
34+
- run: uv run python -m unittest discover -s fluent.syntax
35+
- run: uv run python -m unittest discover -s fluent.runtime
4336

44-
# Test compatibility with the oldest Python version we claim to support,
45-
# and for fluent.runtime's compatibility with a range of fluent.syntax versions.
37+
# Test fluent.runtime's compatibility with a range of fluent.syntax versions.
4638
compatibility:
47-
runs-on: ubuntu-20.04 # https://github.com/actions/setup-python/issues/544
39+
runs-on: ubuntu-22.04
4840
strategy:
4941
matrix:
5042
fluent-syntax:
@@ -53,10 +45,11 @@ jobs:
5345
- fluent.syntax==0.18.1 six
5446
- fluent.syntax==0.17.0 six
5547
steps:
56-
- uses: actions/checkout@v3
57-
- uses: actions/setup-python@v4
48+
- uses: actions/checkout@v6
49+
- uses: astral-sh/setup-uv@v7
5850
with:
59-
python-version: 3.6
60-
- run: python -m pip install ${{ matrix.fluent-syntax }}
61-
- run: python -m pip install ./fluent.runtime
62-
- run: python -m unittest discover -s fluent.runtime
51+
python-version: 3.12
52+
- run: uv venv
53+
- run: uv pip install ${{ matrix.fluent-syntax }}
54+
- run: uv pip install ./fluent.runtime
55+
- run: uv run python -m unittest discover -s fluent.runtime

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python.autoComplete.extraPaths": ["./fluent.syntax"],
3+
"python.analysis.extraPaths": ["./fluent.syntax"],
4+
}

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Project Fluent
2+
3+
This is a collection of Python packages to use the
4+
[Fluent localization system](http://projectfluent.org/):
5+
6+
## `fluent.syntax`
7+
8+
The [syntax package](./fluent.syntax) includes the
9+
parser, serializer, and traversal utilities like `Visitor` and `Transformer`.
10+
You’re looking for this package if you work on tooling for Fluent in Python.
11+
12+
## `fluent.runtime`
13+
14+
The [runtime package](./fluent.runtime) includes the library required to
15+
use Fluent to localize your Python application.
16+
It comes with a `Localization` class to use, based on an implementation of `FluentBundle`.
17+
It uses the tooling parser above to read Fluent files.
18+
19+
## `fluent.pygments`
20+
21+
A [plugin for pygments](./fluent.pygments) to add syntax highlighting to Sphinx.
22+
23+
## Discuss
24+
25+
We’d love to hear your thoughts on Project Fluent! Whether you’re a
26+
localizer looking for a better way to express yourself in your language,
27+
or a developer trying to make your app localizable and multilingual, or
28+
a hacker looking for a project to contribute to, please do get in touch
29+
on the mailing list and the IRC channel.
30+
31+
- Mozilla Discourse: https://discourse.mozilla.org/c/fluent
32+
- Matrix channel: [#fluent:mozilla.org](https://chat.mozilla.org/#/room/#fluent:mozilla.org)
33+
34+
## Get Involved
35+
36+
python-fluent is open-source, licensed under the Apache License, Version
37+
2.0. We encourage everyone to take a look at our code and we’ll listen
38+
to your feedback.

README.rst

Lines changed: 0 additions & 47 deletions
This file was deleted.

dev-requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

fluent.runtime/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# fluent.runtime
2+
3+
Use [Fluent](https://projectfluent.org/) to localize your Python application.
4+
It comes with a `Localization` class to use, based on an implementation of `FluentBundle`.
5+
It uses the parser from `fluent.syntax` to read Fluent files.
6+
7+
```python
8+
from datetime import date
9+
l10n = DemoLocalization("today-is = Today is { $today }")
10+
val = l10n.format_value("today-is", { "today": date.today() })
11+
val # 'Today is Jun 16, 2018'
12+
```
13+
14+
Find the full documentation at https://projectfluent.org/python-fluent/fluent.runtime/.

fluent.runtime/README.rst

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from typing import Callable, Dict
1+
from typing import Callable
22

33
from .types import FluentType, fluent_date, fluent_number
44

55
NUMBER = fluent_number
66
DATETIME = fluent_date
77

88

9-
BUILTINS: Dict[str, Callable[..., FluentType]] = {
9+
BUILTINS: dict[str, Callable[..., FluentType]] = {
1010
"NUMBER": NUMBER,
1111
"DATETIME": DATETIME,
1212
}

fluent.runtime/fluent/runtime/bundle.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Tuple, Union, cast
1+
from typing import TYPE_CHECKING, Any, Callable, Literal, Union, cast
22

33
import babel
44
import babel.numbers
55
import babel.plural
66
from fluent.syntax import ast as FTL
7-
from typing_extensions import Literal
87

98
from .builtins import BUILTINS
109
from .prepare import Compiler
@@ -34,16 +33,16 @@ class FluentBundle:
3433

3534
def __init__(
3635
self,
37-
locales: List[str],
38-
functions: Union[Dict[str, Callable[..., "FluentType"]], None] = None,
36+
locales: list[str],
37+
functions: Union[dict[str, Callable[..., "FluentType"]], None] = None,
3938
use_isolating: bool = True,
4039
):
4140
self.locales = locales
4241
self._functions = {**BUILTINS, **(functions or {})}
4342
self.use_isolating = use_isolating
44-
self._messages: Dict[str, Union[FTL.Message, FTL.Term]] = {}
45-
self._terms: Dict[str, Union[FTL.Message, FTL.Term]] = {}
46-
self._compiled: Dict[str, Message] = {}
43+
self._messages: dict[str, Union[FTL.Message, FTL.Term]] = {}
44+
self._terms: dict[str, Union[FTL.Message, FTL.Term]] = {}
45+
self._compiled: dict[str, Message] = {}
4746
# The compiler is not typed, and this cast is only valid for the public API
4847
self._compiler = cast(
4948
Callable[[Union[FTL.Message, FTL.Term]], Message], Compiler()
@@ -90,8 +89,8 @@ def _lookup(self, entry_id: str, term: bool = False) -> Message:
9089
return self._compiled[compiled_id]
9190

9291
def format_pattern(
93-
self, pattern: Pattern, args: Union[Dict[str, Any], None] = None
94-
) -> Tuple[Union[str, "FluentNone"], List[Exception]]:
92+
self, pattern: Pattern, args: Union[dict[str, Any], None] = None
93+
) -> tuple[Union[str, "FluentNone"], list[Exception]]:
9594
if args is not None:
9695
fluent_args = {
9796
argname: native_to_fluent(argvalue)
@@ -100,7 +99,7 @@ def format_pattern(
10099
else:
101100
fluent_args = {}
102101

103-
errors: List[Exception] = []
102+
errors: list[Exception] = []
104103
env = ResolverEnvironment(
105104
context=self, current=CurrentEnvironment(args=fluent_args), errors=errors
106105
)

0 commit comments

Comments
 (0)