diff --git a/.github/workflows/fluent.runtime.yml b/.github/workflows/fluent.runtime.yml index d9531d95..0eb9647c 100644 --- a/.github/workflows/fluent.runtime.yml +++ b/.github/workflows/fluent.runtime.yml @@ -39,7 +39,7 @@ jobs: run: | python -m pip install wheel python -m pip install --upgrade pip - python -m pip install fluent.syntax==${{ matrix.fluent-syntax }} + python -m pip install fluent.syntax==${{ matrix.fluent-syntax }} six python -m pip install . - name: Test working-directory: ./fluent.runtime @@ -53,11 +53,16 @@ jobs: with: python-version: 3.9 - name: Install dependencies + working-directory: ./fluent.runtime run: | python -m pip install wheel python -m pip install --upgrade pip - python -m pip install flake8==6 - python -m pip install mypy==1 + python -m pip install . + python -m pip install flake8==6 mypy==1 + - name: Install latest fluent.syntax + working-directory: ./fluent.syntax + run: | + python -m pip install . - name: flake8 working-directory: ./fluent.runtime run: | diff --git a/.github/workflows/fluent.syntax.yml b/.github/workflows/fluent.syntax.yml index 46a9b5ab..6eedbf6e 100644 --- a/.github/workflows/fluent.syntax.yml +++ b/.github/workflows/fluent.syntax.yml @@ -35,6 +35,7 @@ jobs: run: | python -m pip install wheel python -m pip install --upgrade pip + python -m pip install . - name: Test working-directory: ./fluent.syntax run: | @@ -47,10 +48,11 @@ jobs: with: python-version: 3.9 - name: Install dependencies + working-directory: ./fluent.syntax run: | python -m pip install --upgrade pip - python -m pip install flake8==6 - python -m pip install mypy==1 + python -m pip install . + python -m pip install flake8==6 mypy==1 - name: flake8 working-directory: ./fluent.syntax run: | diff --git a/fluent.docs/setup.py b/fluent.docs/setup.py index 15436d93..138d54d9 100644 --- a/fluent.docs/setup.py +++ b/fluent.docs/setup.py @@ -1,6 +1,9 @@ -from setuptools import setup, find_namespace_packages +from setuptools import setup setup( name='fluent.docs', - packages=find_namespace_packages(include=['fluent.*']), + packages=['fluent.docs'], + install_requires=[ + 'typing-extensions>=3.7,<5' + ], ) diff --git a/fluent.runtime/fluent/runtime/bundle.py b/fluent.runtime/fluent/runtime/bundle.py index d068b4b6..ea75cddc 100644 --- a/fluent.runtime/fluent/runtime/bundle.py +++ b/fluent.runtime/fluent/runtime/bundle.py @@ -1,7 +1,8 @@ import babel import babel.numbers import babel.plural -from typing import Any, Callable, Dict, List, Literal, TYPE_CHECKING, Tuple, Union, cast +from typing import Any, Callable, Dict, List, TYPE_CHECKING, Tuple, Union, cast +from typing_extensions import Literal from fluent.syntax import ast as FTL diff --git a/fluent.runtime/fluent/runtime/resolver.py b/fluent.runtime/fluent/runtime/resolver.py index 301bc0f1..e4d0caa5 100644 --- a/fluent.runtime/fluent/runtime/resolver.py +++ b/fluent.runtime/fluent/runtime/resolver.py @@ -68,9 +68,7 @@ def modified(self, **replacements: Any) -> Generator['ResolverEnvironment', None yield self self.current = old_current - def modified_for_term_reference( - self, args: Union[Dict[str, Any], None] = None - ) -> contextlib._GeneratorContextManager['ResolverEnvironment']: + def modified_for_term_reference(self, args: Union[Dict[str, Any], None] = None) -> Any: return self.modified(args=args if args is not None else {}, error_for_missing_arg=False) diff --git a/fluent.runtime/fluent/runtime/types.py b/fluent.runtime/fluent/runtime/types.py index 24e18796..a10b254d 100644 --- a/fluent.runtime/fluent/runtime/types.py +++ b/fluent.runtime/fluent/runtime/types.py @@ -7,7 +7,8 @@ from babel import Locale from babel.dates import format_date, format_time, get_datetime_format, get_timezone from babel.numbers import NumberPattern, parse_pattern -from typing import Any, Dict, Literal, Type, TypeVar, Union, cast +from typing import Any, Dict, Type, TypeVar, Union, cast +from typing_extensions import Literal FORMAT_STYLE_DECIMAL = "decimal" FORMAT_STYLE_CURRENCY = "currency" diff --git a/fluent.runtime/setup.py b/fluent.runtime/setup.py index d9c5e631..41a5e11e 100755 --- a/fluent.runtime/setup.py +++ b/fluent.runtime/setup.py @@ -33,6 +33,7 @@ 'attrs', 'babel', 'pytz', + 'typing-extensions>=3.7,<5' ], test_suite='tests', ) diff --git a/fluent.runtime/tox.ini b/fluent.runtime/tox.ini index c0f3920d..511cb53c 100644 --- a/fluent.runtime/tox.ini +++ b/fluent.runtime/tox.ini @@ -12,6 +12,7 @@ deps = attrs==19.1.0 babel==2.7.0 pytz==2019.2 + typing-extensions==3.7 syntax: . commands = ./runtests.py diff --git a/fluent.syntax/fluent/syntax/ast.py b/fluent.syntax/fluent/syntax/ast.py index e22f86b7..d2e48490 100644 --- a/fluent.syntax/fluent/syntax/ast.py +++ b/fluent.syntax/fluent/syntax/ast.py @@ -208,10 +208,10 @@ def parse(self) -> Dict[str, Any]: class StringLiteral(Literal): def parse(self) -> Dict[str, str]: - def from_escape_sequence(matchobj: re.Match[str]) -> str: + def from_escape_sequence(matchobj: Any) -> str: c, codepoint4, codepoint6 = matchobj.groups() if c: - return c + return cast(str, c) codepoint = int(codepoint4 or codepoint6, 16) if codepoint <= 0xD7FF or 0xE000 <= codepoint: return chr(codepoint) diff --git a/fluent.syntax/fluent/syntax/stream.py b/fluent.syntax/fluent/syntax/stream.py index 41035a10..150ac933 100644 --- a/fluent.syntax/fluent/syntax/stream.py +++ b/fluent.syntax/fluent/syntax/stream.py @@ -1,4 +1,5 @@ -from typing import Callable, Literal, Union +from typing import Callable, Union +from typing_extensions import Literal from .errors import ParseError diff --git a/fluent.syntax/setup.py b/fluent.syntax/setup.py index 8c1f95eb..23c17064 100644 --- a/fluent.syntax/setup.py +++ b/fluent.syntax/setup.py @@ -26,5 +26,8 @@ ], packages=['fluent.syntax'], package_data={'fluent.syntax': ['py.typed']}, + install_requires=[ + 'typing-extensions>=3.7,<5' + ], test_suite='tests.syntax' ) diff --git a/fluent.syntax/tox.ini b/fluent.syntax/tox.ini index 2ed33bdb..db0448bc 100644 --- a/fluent.syntax/tox.ini +++ b/fluent.syntax/tox.ini @@ -7,4 +7,6 @@ skipsdist=True [testenv] setenv = PYTHONPATH = {toxinidir} +deps = + typing-extensions==3.7 commands = ./runtests.py