messageformat2 0.1.0__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- messageformat2-0.1.1/.github/dependabot.yml +27 -0
- messageformat2-0.1.1/.github/workflows/ci.yml +34 -0
- messageformat2-0.1.1/.github/workflows/release.yml +31 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/.gitignore +1 -3
- {messageformat2-0.1.0 → messageformat2-0.1.1}/.readthedocs.yaml +5 -5
- {messageformat2-0.1.0 → messageformat2-0.1.1}/CONTRIBUTING.md +1 -1
- {messageformat2-0.1.0 → messageformat2-0.1.1}/PKG-INFO +12 -29
- {messageformat2-0.1.0 → messageformat2-0.1.1}/README.md +1 -1
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/explanation.md +35 -50
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/index.md +0 -10
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/__init__.py +1 -1
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/builtins.py +1 -1
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/parser.py +1 -1
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/runtime.py +2 -2
- {messageformat2-0.1.0 → messageformat2-0.1.1}/pyproject.toml +18 -23
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/test_parser.py +1 -1
- messageformat2-0.1.1/uv.lock +776 -0
- messageformat2-0.1.0/.github/workflows/ci.yml +0 -34
- messageformat2-0.1.0/docs/reference.md +0 -12
- messageformat2-0.1.0/messageformat2.egg-info/PKG-INFO +0 -148
- messageformat2-0.1.0/messageformat2.egg-info/SOURCES.txt +0 -70
- messageformat2-0.1.0/messageformat2.egg-info/dependency_links.txt +0 -1
- messageformat2-0.1.0/messageformat2.egg-info/entry_points.txt +0 -2
- messageformat2-0.1.0/messageformat2.egg-info/requires.txt +0 -20
- messageformat2-0.1.0/messageformat2.egg-info/top_level.txt +0 -1
- messageformat2-0.1.0/requirements.dev.txt +0 -176
- messageformat2-0.1.0/requirements.docs.txt +0 -96
- messageformat2-0.1.0/requirements.txt +0 -4
- messageformat2-0.1.0/setup.cfg +0 -4
- {messageformat2-0.1.0 → messageformat2-0.1.1}/LICENSE +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/builtins.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/datamodel.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/errors.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/getting_started.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/howto/datamodel.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/howto/errors.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/howto/formatter.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/howto/selector.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/message.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/docs/mf2.md +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/cli.py +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/datamodel.py +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/errors.py +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/messageformat2/message.py +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/mkdocs.yml +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/__init__.py +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/complex_message_1.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/complex_message_2.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/complex_message_3.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_1.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_10.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_11.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_12.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_13.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_14.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_15.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_16.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_2.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_3.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_4.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_5.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_6.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_7.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_8.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_9.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_escapes_1.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/simple_message_escapes_2.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_annotations_1.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_annotations_2.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_annotations_3.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_annotations_4.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_annotations_5.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_statement_1.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/data/unsupported_statement_2.txt +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/test_regex.py +0 -0
- {messageformat2-0.1.0 → messageformat2-0.1.1}/tests/test_runtime.py +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "github-actions"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: "weekly"
|
|
7
|
+
day: "monday"
|
|
8
|
+
time: "09:00"
|
|
9
|
+
timezone: "Europe/Zurich"
|
|
10
|
+
cooldown:
|
|
11
|
+
default-days: 7
|
|
12
|
+
groups:
|
|
13
|
+
github-actions:
|
|
14
|
+
patterns: ["*"]
|
|
15
|
+
|
|
16
|
+
- package-ecosystem: "pip"
|
|
17
|
+
directory: "/"
|
|
18
|
+
schedule:
|
|
19
|
+
interval: "weekly"
|
|
20
|
+
day: "monday"
|
|
21
|
+
time: "09:00"
|
|
22
|
+
timezone: "Europe/Zurich"
|
|
23
|
+
cooldown:
|
|
24
|
+
default-days: 7
|
|
25
|
+
groups:
|
|
26
|
+
python-dependencies:
|
|
27
|
+
patterns: ["*"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
ci:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
|
|
19
|
+
- name: Install the latest version of uv and set the python version
|
|
20
|
+
uses: astral-sh/setup-uv@v7
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Lint code 🧹
|
|
25
|
+
run: |
|
|
26
|
+
uv run ruff check tests/ messageformat2/ --exclude messageformat2/cli.py
|
|
27
|
+
|
|
28
|
+
- name: Type check 🏷
|
|
29
|
+
run: |
|
|
30
|
+
uv run ty check messageformat2/ tests/
|
|
31
|
+
|
|
32
|
+
- name: Run tests 🧪
|
|
33
|
+
run: |
|
|
34
|
+
uv run pytest --no-cov --doctest-modules
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Upload To PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
pypi-publish:
|
|
13
|
+
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment: release
|
|
16
|
+
permissions:
|
|
17
|
+
id-token: write
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
|
|
22
|
+
- name: Install the latest version of uv and set the python version
|
|
23
|
+
uses: astral-sh/setup-uv@v7
|
|
24
|
+
with:
|
|
25
|
+
python-version: '3.14'
|
|
26
|
+
|
|
27
|
+
- name: Build package 📦
|
|
28
|
+
run: uv build
|
|
29
|
+
|
|
30
|
+
- name: Publish package distributions to PyPI
|
|
31
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -9,11 +9,11 @@ build:
|
|
|
9
9
|
os: ubuntu-22.04
|
|
10
10
|
tools:
|
|
11
11
|
python: "3.12"
|
|
12
|
+
jobs:
|
|
13
|
+
post_create_environment:
|
|
14
|
+
- pip install uv
|
|
15
|
+
post_install:
|
|
16
|
+
- uv sync --group docs
|
|
12
17
|
|
|
13
18
|
mkdocs:
|
|
14
19
|
configuration: mkdocs.yml
|
|
15
|
-
|
|
16
|
-
# Optionally declare the Python requirements required to build your docs
|
|
17
|
-
python:
|
|
18
|
-
install:
|
|
19
|
-
- requirements: requirements.docs.txt
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: messageformat2
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Python implementation of Unicode MessageFormat 2.0
|
|
5
|
+
Project-URL: Homepage, https://github.com/tomasr8/messageformat2
|
|
6
|
+
Project-URL: Github, https://github.com/tomasr8/messageformat2
|
|
5
7
|
Author-email: Tomas Roun <tomas.roun8@gmail.com>
|
|
6
8
|
License: MIT License
|
|
7
9
|
|
|
@@ -24,10 +26,8 @@ License: MIT License
|
|
|
24
26
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
27
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
28
|
SOFTWARE.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Project-URL: Github, https://github.com/tomasr8/messageformat2
|
|
30
|
-
Keywords: i18n,internationalization,localization,messageformat,messageformat 2,cldr,gettext
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Keywords: cldr,gettext,i18n,internationalization,localization,messageformat,messageformat 2
|
|
31
31
|
Classifier: License :: OSI Approved :: MIT License
|
|
32
32
|
Classifier: Operating System :: OS Independent
|
|
33
33
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -36,30 +36,13 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
36
36
|
Classifier: Topic :: Software Development :: Internationalization
|
|
37
37
|
Classifier: Topic :: Software Development :: Localization
|
|
38
38
|
Requires-Python: >=3.12
|
|
39
|
+
Requires-Dist: babel==2.17.0
|
|
40
|
+
Requires-Dist: click==8.3.1
|
|
39
41
|
Description-Content-Type: text/markdown
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Requires-Dist: build; extra == "dev"
|
|
45
|
-
Requires-Dist: twine; extra == "dev"
|
|
46
|
-
Requires-Dist: uv; extra == "dev"
|
|
47
|
-
Requires-Dist: pytest; extra == "dev"
|
|
48
|
-
Requires-Dist: pytest-snapshot; extra == "dev"
|
|
49
|
-
Requires-Dist: pytest-cov; extra == "dev"
|
|
50
|
-
Requires-Dist: ruff; extra == "dev"
|
|
51
|
-
Requires-Dist: pyright; extra == "dev"
|
|
52
|
-
Requires-Dist: mkdocs; extra == "dev"
|
|
53
|
-
Requires-Dist: mkdocstrings[python]; extra == "dev"
|
|
54
|
-
Requires-Dist: mkdocs-material; extra == "dev"
|
|
55
|
-
Provides-Extra: docs
|
|
56
|
-
Requires-Dist: mkdocs; extra == "docs"
|
|
57
|
-
Requires-Dist: mkdocstrings[python]; extra == "docs"
|
|
58
|
-
Requires-Dist: mkdocs-material; extra == "docs"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
# MessageFormat2 [](https://messageformat2.readthedocs.io/en/latest/?badge=latest) [](https://github.com/tomasr8/messageformat2/workflows/CI/badge.svg) [](https://microsoft.github.io/pyright/)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
# MessageFormat2 [](https://messageformat2.readthedocs.io/en/latest/?badge=latest) [](https://github.com/tomasr8/messageformat2/workflows/CI/badge.svg)
|
|
63
46
|
|
|
64
47
|
This is a Python implementation of the [Unicode Message Format 2.0
|
|
65
48
|
specification](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
# MessageFormat2 [](https://messageformat2.readthedocs.io/en/latest/?badge=latest) [](https://github.com/tomasr8/messageformat2/workflows/CI/badge.svg)
|
|
3
|
+
# MessageFormat2 [](https://messageformat2.readthedocs.io/en/latest/?badge=latest) [](https://github.com/tomasr8/messageformat2/workflows/CI/badge.svg)
|
|
4
4
|
|
|
5
5
|
This is a Python implementation of the [Unicode Message Format 2.0
|
|
6
6
|
specification](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html).
|
|
@@ -1,52 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
**understanding-oriented** approach. You'll get a
|
|
3
|
-
chance to read about the background of the project,
|
|
4
|
-
as well as reasoning about how it was implemented.
|
|
1
|
+
## Runtime model
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- Give context and background on your library
|
|
10
|
-
- Explain why you created it
|
|
11
|
-
- Provide multiple examples and approaches of how
|
|
12
|
-
to work with it
|
|
13
|
-
- Help the reader make connections
|
|
14
|
-
- Avoid writing instructions or technical descriptions
|
|
15
|
-
here
|
|
16
|
-
|
|
17
|
-
Invalid syntax
|
|
18
|
-
A complex message cannot start with leading whitespace. Such a message is treated as a simple message by the grammar
|
|
19
|
-
|
|
20
|
-
## Whitespace
|
|
21
|
-
|
|
22
|
-
This library implements the [grammar](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html#complete-abnf) exactly as specified which includes whitespace.
|
|
23
|
-
According to the grammar, complex messages (messages containing declarations and/or the match block) cannot have a leading whitespace. For example, this message:
|
|
24
|
-
|
|
25
|
-
```python
|
|
26
|
-
.match {$count :integer}
|
|
27
|
-
* {{count is {$count}}}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
will be parsed as a simple message (message not containing any declarations/match blocks, only patterns `{...}`). The parsing will fail
|
|
31
|
-
because a pattern cannot contain unescaped `{`.
|
|
32
|
-
|
|
33
|
-
When defining complex messages using multiline strings, don't forget to use a leading `\` to remove the first newline character:
|
|
34
|
-
|
|
35
|
-
```python
|
|
36
|
-
Message("""\ # <- notice the backslash
|
|
37
|
-
.match {$count: integer}
|
|
38
|
-
* {{count is {$count}}}""")
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```python
|
|
42
|
-
Message(""".match {$count: integer}
|
|
43
|
-
* {{count is {$count}}}""")
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Computation model
|
|
47
|
-
|
|
48
|
-
All expressions are lazily evaluated at the time of use. If the same variable if referenced more than once, it will be evaaluated more than once.
|
|
49
|
-
IF you have formatters/selectors with side effects be careful.
|
|
3
|
+
All expressions are lazily evaluated at the time of use.
|
|
4
|
+
If the same variable is referenced more than once, it will also be evaluated more than once.
|
|
5
|
+
Pay attention when providing custom formatters/selectors with side effects:
|
|
50
6
|
|
|
51
7
|
```python
|
|
52
8
|
counter = 0
|
|
@@ -66,21 +22,50 @@ print(counter) # -> 2
|
|
|
66
22
|
|
|
67
23
|
## Function composition
|
|
68
24
|
|
|
69
|
-
Composition of functions is only allowed for the same functions
|
|
25
|
+
Composition of functions is only allowed for the same functions:
|
|
70
26
|
|
|
71
27
|
```python
|
|
72
28
|
.local $x {42 :integer}
|
|
73
29
|
{{x = {$x :integer}}}
|
|
74
30
|
```
|
|
75
31
|
|
|
32
|
+
This will raise an exception:
|
|
33
|
+
|
|
76
34
|
```python
|
|
77
35
|
.local $x {42 :integer}
|
|
78
36
|
{{x = {$x :string}}}
|
|
79
37
|
```
|
|
80
38
|
|
|
81
|
-
Options are merged together with the later options overwritting any earlier options
|
|
39
|
+
Options are merged together with the later options overwritting any earlier options:
|
|
82
40
|
|
|
83
41
|
```python
|
|
84
42
|
.local $date {|2024-05-10| :date style=short}
|
|
85
43
|
{{date = {$date :date style=full}}}
|
|
86
44
|
```
|
|
45
|
+
|
|
46
|
+
## Whitespace
|
|
47
|
+
|
|
48
|
+
This library implements the [grammar](https://www.unicode.org/reports/tr35/tr35-72/tr35-messageFormat.html#complete-abnf) exactly as specified which includes whitespace.
|
|
49
|
+
According to the grammar, complex messages (messages containing declarations and/or the match block) cannot have a leading whitespace. For example, this message:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
.match {$count :integer}
|
|
53
|
+
* {{count is {$count}}}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
will be parsed as a simple message (message not containing any declarations/match blocks, only patterns `{...}`). The parsing will fail because a pattern cannot contain unescaped `{`.
|
|
57
|
+
|
|
58
|
+
When defining complex messages using multiline strings, don't forget to use a leading `\` to remove the first newline character:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
Message("""\ # <- notice the backslash
|
|
62
|
+
.match {$count: integer}
|
|
63
|
+
* {{count is {$count}}}""")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Alternatively, you can use this style:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
Message(""".match {$count: integer}
|
|
70
|
+
* {{count is {$count}}}""")
|
|
71
|
+
```
|
|
@@ -25,13 +25,3 @@ The `messageformat2` library includes:
|
|
|
25
25
|
- Message extraction and loading - This will be provided once a format for MF2
|
|
26
26
|
[message resources](https://github.com/eemeli/message-resource-wg) is
|
|
27
27
|
standardized.
|
|
28
|
-
|
|
29
|
-
## Table Of Contents
|
|
30
|
-
|
|
31
|
-
1. [Tutorials](tutorials.md)
|
|
32
|
-
2. [How-To Guides](how-to-guides.md)
|
|
33
|
-
3. [Reference](reference.md)
|
|
34
|
-
4. [Explanation](explanation.md)
|
|
35
|
-
|
|
36
|
-
Quickly find what you're looking for depending on your use case by looking at
|
|
37
|
-
the different pages.
|
|
@@ -150,7 +150,7 @@ def integer_selector(value: Any, locale: Locale, options: dict[str, Any], keys:
|
|
|
150
150
|
return exact_keys + keyword_keys
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def format_datetime( # noqa: PLR0915, PLR0913
|
|
153
|
+
def format_datetime( # noqa: PLR0915, PLR0913
|
|
154
154
|
dt: _datetime.datetime,
|
|
155
155
|
locale: Locale,
|
|
156
156
|
dateStyle: Literal["full", "long", "medium", "short"] | None = None,
|
|
@@ -165,7 +165,7 @@ def parse_simple_message(queue: Queue) -> PatternMessage:
|
|
|
165
165
|
y = pattern[0]
|
|
166
166
|
match (x, y):
|
|
167
167
|
case (str(), str()):
|
|
168
|
-
pattern = simple_start[:-1]
|
|
168
|
+
pattern = [*simple_start[:-1], x + y, *pattern[1:]]
|
|
169
169
|
return PatternMessage(declarations=[], pattern=pattern)
|
|
170
170
|
case _:
|
|
171
171
|
return PatternMessage(declarations=[], pattern=simple_start + pattern)
|
|
@@ -165,7 +165,7 @@ def sort_variants(pref: list, variants: list[Variant]) -> Pattern:
|
|
|
165
165
|
minpref = len(matches)
|
|
166
166
|
for s in sortable:
|
|
167
167
|
matchpref = minpref
|
|
168
|
-
key = s[1].keys[i]
|
|
168
|
+
key = s[1].keys[i] # type: ignore[index]
|
|
169
169
|
if not isinstance(key, CatchallKey):
|
|
170
170
|
assert isinstance(key, Literal)
|
|
171
171
|
ks = key.value
|
|
@@ -173,7 +173,7 @@ def sort_variants(pref: list, variants: list[Variant]) -> Pattern:
|
|
|
173
173
|
s[0] = matchpref
|
|
174
174
|
sortable.sort(key=lambda x: x[0])
|
|
175
175
|
i = i - 1
|
|
176
|
-
return sortable[0][1].value
|
|
176
|
+
return sortable[0][1].value # type: ignore[index]
|
|
177
177
|
|
|
178
178
|
|
|
179
179
|
def resolve_selector(selector: Expression, ctx: FormattingContext) -> Any | LazyValue:
|
|
@@ -23,24 +23,21 @@ classifiers = [
|
|
|
23
23
|
"Topic :: Software Development :: Internationalization",
|
|
24
24
|
"Topic :: Software Development :: Localization",
|
|
25
25
|
]
|
|
26
|
-
dependencies = ["Babel", "click"]
|
|
26
|
+
dependencies = ["Babel==2.17.0", "click==8.3.1"]
|
|
27
27
|
dynamic = ["version"]
|
|
28
28
|
|
|
29
|
-
[
|
|
29
|
+
[dependency-groups]
|
|
30
30
|
dev = [
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"mkdocs",
|
|
40
|
-
"mkdocstrings[python]",
|
|
41
|
-
"mkdocs-material",
|
|
31
|
+
"pytest==9.0.1",
|
|
32
|
+
"pytest-snapshot==0.9.0",
|
|
33
|
+
"pytest-cov==7.0.0",
|
|
34
|
+
"ruff==0.14.7",
|
|
35
|
+
"ty==0.0.1a30",
|
|
36
|
+
"mkdocs==1.6.1",
|
|
37
|
+
"mkdocstrings[python]==1.0.0",
|
|
38
|
+
"mkdocs-material==9.7.0",
|
|
42
39
|
]
|
|
43
|
-
docs = ["mkdocs", "mkdocstrings[python]", "mkdocs-material"]
|
|
40
|
+
docs = ["mkdocs==1.6.1", "mkdocstrings[python]==1.0.0", "mkdocs-material==9.7.0"]
|
|
44
41
|
|
|
45
42
|
[project.urls]
|
|
46
43
|
Homepage = "https://github.com/tomasr8/messageformat2"
|
|
@@ -49,19 +46,16 @@ Github = "https://github.com/tomasr8/messageformat2"
|
|
|
49
46
|
[project.scripts]
|
|
50
47
|
mf2 = "messageformat2.cli:cli"
|
|
51
48
|
|
|
52
|
-
[tool.pyright]
|
|
53
|
-
include = ["tests", "messageformat2"]
|
|
54
|
-
|
|
55
49
|
[tool.ruff.lint]
|
|
56
50
|
select = ["ALL"]
|
|
57
51
|
ignore = [
|
|
58
52
|
"D",
|
|
59
53
|
"ANN002",
|
|
60
54
|
"ANN003",
|
|
61
|
-
"ANN101",
|
|
62
55
|
"ANN204",
|
|
63
56
|
"ANN401",
|
|
64
57
|
"COM812",
|
|
58
|
+
"C901",
|
|
65
59
|
"BLE001",
|
|
66
60
|
"RET503",
|
|
67
61
|
"ISC001",
|
|
@@ -69,6 +63,7 @@ ignore = [
|
|
|
69
63
|
"N803",
|
|
70
64
|
"N806",
|
|
71
65
|
"N818",
|
|
66
|
+
"PLR0912",
|
|
72
67
|
"S101",
|
|
73
68
|
]
|
|
74
69
|
|
|
@@ -81,12 +76,12 @@ line-length = 120
|
|
|
81
76
|
[tool.ruff.lint.isort]
|
|
82
77
|
lines-after-imports = 2
|
|
83
78
|
|
|
84
|
-
[tool.
|
|
79
|
+
[tool.hatch.build.targets.wheel]
|
|
85
80
|
packages = ["messageformat2"]
|
|
86
81
|
|
|
87
|
-
[tool.
|
|
88
|
-
|
|
82
|
+
[tool.hatch.version]
|
|
83
|
+
path = "messageformat2/__init__.py"
|
|
89
84
|
|
|
90
85
|
[build-system]
|
|
91
|
-
requires = ["
|
|
92
|
-
build-backend = "
|
|
86
|
+
requires = ["hatchling==1.28.0"]
|
|
87
|
+
build-backend = "hatchling.build"
|
|
@@ -16,7 +16,7 @@ from messageformat2.parser import parse
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def ruff_format(source):
|
|
19
|
-
p = Popen(["ruff", "format", "-"], shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE) # noqa:
|
|
19
|
+
p = Popen(["ruff", "format", "-"], shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE) # noqa: S607
|
|
20
20
|
output, err = p.communicate(source.encode("utf-8"))
|
|
21
21
|
assert not err
|
|
22
22
|
return output
|