Skip to content

Commit ae416d0

Browse files
authored
Drop Python 2.7, 3.5 support, add 3.6-3.9 for fluent.runtime, fluent.pygments (#163)
* Declare compat with current python versions, drop 2.7, 3.5 Also adjust testing matrix to that. * Drop six, but keep it installed in tests * Use pyupgrade --py36-plus to modernize syntax. * Update version number and CHANGELOG * Add six to install dependencies, because fluent.syntax didn't. * Also dropping dependencies on mock, which I didn't spot in the updates via pyupgrade.
1 parent 7e1c4be commit ae416d0

34 files changed

+90
-135
lines changed

.github/workflows/fluent.integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
python -m pip install wheel
3939
python -m pip install --upgrade pip
40-
python -m pip install . mock
40+
python -m pip install .
4141
- name: Install latest fluent.syntax
4242
working-directory: ./fluent.syntax
4343
run: |

.github/workflows/fluent.runtime.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ jobs:
2424
runs-on: ubuntu-latest
2525
strategy:
2626
matrix:
27-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, pypy2, pypy3]
28-
fluent-syntax: [0.17.0]
27+
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
28+
fluent-syntax: [0.18.1]
29+
include:
30+
- python-version: 3.9
31+
fluent-syntax: 0.17.0
2932
steps:
3033
- uses: actions/checkout@v2
3134
- uses: actions/setup-python@v2
@@ -37,7 +40,7 @@ jobs:
3740
python -m pip install wheel
3841
python -m pip install --upgrade pip
3942
python -m pip install fluent.syntax==${{ matrix.fluent-syntax }}
40-
python -m pip install . mock
43+
python -m pip install .
4144
- name: Test
4245
working-directory: ./fluent.runtime
4346
run: |
@@ -49,7 +52,7 @@ jobs:
4952
- uses: actions/checkout@v2
5053
- uses: actions/setup-python@v2
5154
with:
52-
python-version: 3.7
55+
python-version: 3.9
5356
- name: Install dependencies
5457
run: |
5558
python -m pip install wheel

fluent.pygments/CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
fluent.runtime 2.0 (TBD)
5+
-----------------------------------
6+
7+
* Drop support for Python 2.7 and 3.5
8+
* Add support for Python 3.6 through 3.9
9+
410
fluent.pygments 1.0 (May 20, 2020)
511
----------------------------------
612

fluent.pygments/fluent/pygments/cli.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, print_function, unicode_literals
2-
31
import argparse
42
import sys
53

fluent.pygments/fluent/pygments/lexer.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, print_function, unicode_literals
2-
31
from fluent.syntax import ast as FTL
42
from fluent.syntax import parse
53

@@ -38,7 +36,7 @@ def get_tokens_unprocessed(self, text):
3836
}
3937

4038

41-
class Tokenizer(object):
39+
class Tokenizer:
4240
def __init__(self, text):
4341
self.text = text
4442
self.ast = parse(text)
@@ -49,21 +47,18 @@ def tokenize(self, node=None):
4947
if isinstance(node, (FTL.Annotation, FTL.Span)):
5048
return
5149
if isinstance(node, FTL.SyntaxNode):
52-
for token in self.tokenize_node(node):
53-
yield token
50+
yield from self.tokenize_node(node)
5451
elif isinstance(node, list):
5552
for child in node:
56-
for token in self.tokenize(child):
57-
yield token
53+
yield from self.tokenize(child)
5854

5955
def tokenize_node(self, node):
6056
nodename = type(node).__name__
6157
if nodename in ATOMIC:
6258
yield self._token(node, ATOMIC[nodename])
6359
else:
64-
tokenize = getattr(self, 'tokenize_{}'.format(nodename), self.generic_tokenize)
65-
for token in tokenize(node):
66-
yield token
60+
tokenize = getattr(self, f'tokenize_{nodename}', self.generic_tokenize)
61+
yield from tokenize(node)
6762

6863
def generic_tokenize(self, node):
6964
children = [
@@ -74,13 +69,11 @@ def generic_tokenize(self, node):
7469
key=lambda child: child.span.start if isinstance(child, FTL.SyntaxNode) else child[0].span.start
7570
)
7671
for child in children:
77-
for token in self.tokenize(child):
78-
yield token
72+
yield from self.tokenize(child)
7973

8074
def tokenize_Variant(self, node):
8175
yield self._token(node.key, Token.Name.Attribute)
82-
for token in self.tokenize(node.value):
83-
yield token
76+
yield from self.tokenize(node.value)
8477

8578
def _token(self, node, token):
8679
return (

fluent.pygments/setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[metadata]
2-
version=1.0
2+
version=2.0
33

44
[bdist_wheel]
55
universal=1
@@ -17,7 +17,6 @@ not_skip=__init__.py
1717
install_requires =
1818
pygments
1919
fluent.syntax
20-
six
2120

2221
[options.entry_points]
2322
pygments.lexers =

fluent.pygments/setup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
'Development Status :: 3 - Alpha',
2020
'Intended Audience :: Developers',
2121
'License :: OSI Approved :: Apache Software License',
22-
'Programming Language :: Python :: 2.7',
23-
'Programming Language :: Python :: 3.5',
22+
'Programming Language :: Python :: 3.6',
23+
'Programming Language :: Python :: 3.7',
24+
'Programming Language :: Python :: 3.8',
25+
'Programming Language :: Python :: 3.9',
26+
'Programming Language :: Python :: 3 :: Only',
2427
],
2528
packages=['fluent', 'fluent.pygments'],
26-
tests_require=['six'],
2729
test_suite='tests.pygments'
2830
)

fluent.pygments/tests/pygments/test_lexer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, print_function, unicode_literals
2-
31
import unittest
42
from pygments.token import Token
53

fluent.runtime/CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
fluent.runtime 0.4 (TBD)
5+
-----------------------------------
6+
7+
* Drop support for Python 2.7 and 3.5
8+
* Add support for Python 3.6 through 3.9
9+
410
fluent.runtime 0.3.1 (May 20, 2020)
511
-----------------------------------
612

fluent.runtime/fluent/runtime/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, unicode_literals
2-
31
import babel
42
import babel.numbers
53
import babel.plural
@@ -28,7 +26,7 @@ def FluentResource(source):
2826
return parser.parse(source)
2927

3028

31-
class FluentBundle(object):
29+
class FluentBundle:
3230
"""
3331
Bundles are single-language stores of translations. They are
3432
aggregate parsed Fluent resources in the Fluent syntax and can

0 commit comments

Comments
 (0)