Skip to content

Commit 763c290

Browse files
authored
Upgrade to Python 3.10 (facebookresearch#723)
1 parent 322440b commit 763c290

165 files changed

Lines changed: 1430 additions & 1511 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/_build_wheels.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
torch: ['2.2.0', '2.2.1', '2.2.2']
28-
py: ['3.9', '3.10', '3.11', '3.12']
28+
py: ['3.10', '3.11', '3.12']
2929
variant: ['cpu', 'cu118', 'cu121']
3030
sanitizers: ['nosan']
3131
with:
@@ -42,7 +42,7 @@ jobs:
4242
fail-fast: false
4343
matrix:
4444
torch: ['2.3.0', '2.3.1']
45-
py: ['3.9', '3.10', '3.11', '3.12']
45+
py: ['3.10', '3.11', '3.12']
4646
variant: ['cpu', 'cu118', 'cu121']
4747
sanitizers: ['nosan']
4848
with:
@@ -59,7 +59,7 @@ jobs:
5959
fail-fast: false
6060
matrix:
6161
torch: ['2.4.0']
62-
py: ['3.9', '3.10', '3.11', '3.12']
62+
py: ['3.10', '3.11', '3.12']
6363
variant: ['cpu', 'cu118', 'cu121']
6464
sanitizers: ['nosan']
6565
include:
@@ -93,7 +93,7 @@ jobs:
9393
fail-fast: false
9494
matrix:
9595
torch: ['2.4.0']
96-
py: ['3.9', '3.10', '3.11', '3.12']
96+
py: ['3.10', '3.11', '3.12']
9797
with:
9898
torch: ${{ matrix.torch }}
9999
py: ${{ matrix.py }}
@@ -107,7 +107,7 @@ jobs:
107107
fail-fast: false
108108
matrix:
109109
torch: ['2.4.0']
110-
py: ['3.9', '3.10', '3.11', '3.12']
110+
py: ['3.10', '3.11', '3.12']
111111
variant: ['cu121']
112112
with:
113113
torch: ${{ matrix.torch }}
@@ -125,7 +125,7 @@ jobs:
125125
fail-fast: false
126126
matrix:
127127
torch: ['2.4.0']
128-
py: ['3.9', '3.10', '3.11', '3.12']
128+
py: ['3.10', '3.11', '3.12']
129129
with:
130130
torch: ${{ matrix.torch }}
131131
py: ${{ matrix.py }}

.github/workflows/_publish.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
torch: ['2.2.0', '2.2.1', '2.2.2']
23-
py: ['3.9', '3.10', '3.11', '3.12']
23+
py: ['3.10', '3.11', '3.12']
2424
variant: ['cpu', 'cu118', 'cu121']
2525
max-parallel: 1
2626
uses: ./.github/workflows/_publish_s3.yaml
@@ -36,7 +36,7 @@ jobs:
3636
strategy:
3737
matrix:
3838
torch: ['2.3.0', '2.3.1']
39-
py: ['3.9', '3.10', '3.11', '3.12']
39+
py: ['3.10', '3.11', '3.12']
4040
variant: ['cpu', 'cu118', 'cu121']
4141
max-parallel: 1
4242
uses: ./.github/workflows/_publish_s3.yaml
@@ -52,7 +52,7 @@ jobs:
5252
strategy:
5353
matrix:
5454
torch: ['2.4.0']
55-
py: ['3.9', '3.10', '3.11', '3.12']
55+
py: ['3.10', '3.11', '3.12']
5656
variant: ['cpu', 'cu118', 'cu121']
5757
max-parallel: 1
5858
uses: ./.github/workflows/_publish_s3.yaml
@@ -68,7 +68,7 @@ jobs:
6868
strategy:
6969
matrix:
7070
torch: ['2.4.0']
71-
py: ['3.9', '3.10', '3.11', '3.12']
71+
py: ['3.10', '3.11', '3.12']
7272
max-parallel: 1
7373
uses: ./.github/workflows/_publish_s3.yaml
7474
with:
@@ -91,7 +91,7 @@ jobs:
9191
strategy:
9292
matrix:
9393
torch: ['2.4.0']
94-
py: ['3.9', '3.10', '3.11', '3.12']
94+
py: ['3.10', '3.11', '3.12']
9595
variant: ['cu121']
9696
max-parallel: 1
9797
with:
@@ -109,7 +109,7 @@ jobs:
109109
strategy:
110110
matrix:
111111
torch: ['2.4.0']
112-
py: ['3.9', '3.10', '3.11', '3.12']
112+
py: ['3.10', '3.11', '3.12']
113113
max-parallel: 1
114114
with:
115115
os: 'macos'

.github/workflows/ci_build_wheels.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646

4747
# Lowest Supported Version
4848
- torch: '2.2.0'
49-
py: '3.9'
49+
py: '3.10'
5050
variant: 'cpu'
5151
sanitizers: 'nosan'
5252
run_integration_tests: false
@@ -69,7 +69,7 @@ jobs:
6969

7070
# Lowest Supported Version
7171
- torch: '2.2.0'
72-
py: '3.9'
72+
py: '3.10'
7373
with:
7474
torch: ${{ matrix.torch }}
7575
py: ${{ matrix.py }}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,19 @@ matrix shows the supported combinations.
9393
<tr>
9494
<td rowspan=3><code>HEAD</code></td>
9595
<td><code>2.4.0</code></td>
96-
<td><code>&gt;=3.9</code>, <code>&lt;=3.12</code></td>
96+
<td><code>&gt;=3.10</code>, <code>&lt;=3.12</code></td>
9797
<td><code>cpu</code>, <code>cu118</code>, <code>cu121</code></td>
9898
<td><code>x86_64</code></td>
9999
</tr>
100100
<tr>
101101
<td><code>2.3.0</code>, <code>2.3.1</code></td>
102-
<td><code>&gt;=3.9</code>, <code>&lt;=3.12</code></td>
102+
<td><code>&gt;=3.10</code>, <code>&lt;=3.12</code></td>
103103
<td><code>cpu</code>, <code>cu118</code>, <code>cu121</code></td>
104104
<td><code>x86_64</code></td>
105105
</tr>
106106
<tr>
107107
<td><code>2.2.0</code>, <code>2.2.1</code>, <code>2.2.2</code></td>
108-
<td><code>&gt;=3.9</code>, <code>&lt;=3.12</code></td>
108+
<td><code>&gt;=3.10</code>, <code>&lt;=3.12</code></td>
109109
<td><code>cpu</code>, <code>cu118</code>, <code>cu121</code></td>
110110
<td><code>x86_64</code></td>
111111
</tr>

native/python/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from __future__ import annotations
88

99
from os import path
10-
from typing import Final, Optional
10+
from typing import Final
1111

1212
import torch
1313
from setuptools import Command, find_packages, setup
@@ -88,7 +88,7 @@ def run(self) -> None:
8888

8989
self._cmake_install(component="python")
9090

91-
def _cmake_install(self, component: Optional[str] = None) -> None:
91+
def _cmake_install(self, component: str | None = None) -> None:
9292
cmd = ["cmake", "--install", self.cmake_build_dir]
9393

9494
if component:

native/python/src/fairseq2n/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from ctypes import CDLL, RTLD_GLOBAL
1414
from os import environ
1515
from pathlib import Path
16-
from typing import Optional
1716

1817
from fairseq2n.config import (
1918
_CUDA_VERSION,
@@ -59,7 +58,7 @@ def supports_cuda() -> bool:
5958
return _SUPPORTS_CUDA
6059

6160

62-
def cuda_version() -> Optional[tuple[int, int]]:
61+
def cuda_version() -> tuple[int, int] | None:
6362
"""Return the version of CUDA that fairseq2n supports.
6463
6564
:returns:
@@ -124,7 +123,7 @@ def _load_sndfile() -> None:
124123
_libs.append(libsndfile)
125124

126125

127-
def _load_shared_library(lib_name: str) -> Optional[CDLL]:
126+
def _load_shared_library(lib_name: str) -> CDLL | None:
128127
# In Conda environments, we always expect native libraries to be part of the
129128
# environment, so we skip the default lookup rules of the dynamic linker.
130129
if not "CONDA_PREFIX" in environ:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ disable_error_code = "type-abstract,typeddict-unknown-key"
2121
disallow_untyped_calls = false
2222
disallow_untyped_decorators = false
2323
files = "setup.py,src,tests"
24-
python_version = 3.9
24+
python_version = "3.10"
2525
show_error_codes = true
2626
show_error_context = true
2727
strict = true

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"Intended Audience :: Science/Research",
3434
"License :: OSI Approved :: MIT License",
3535
"Programming Language :: Python :: 3",
36-
"Programming Language :: Python :: 3.9",
3736
"Programming Language :: Python :: 3.10",
3837
"Programming Language :: Python :: 3.11",
3938
"Programming Language :: Python :: 3.12",
@@ -46,7 +45,7 @@
4645
"fairseq2.assets.cards": ["**/*.yaml"],
4746
},
4847
zip_safe=False,
49-
python_requires=">=3.9",
48+
python_requires=">=3.10",
5049
install_requires=[
5150
"editdistance~=0.8",
5251
"fairseq2n" + fairseq2n_version_spec,
@@ -62,7 +61,7 @@
6261
"tiktoken~=0.7",
6362
"torcheval~=0.0.6",
6463
"tqdm~=4.62",
65-
"typing_extensions~=4.12;python_version<'3.10'",
64+
"typing_extensions~=4.12",
6665
],
6766
extras_require={
6867
"arrow": ["pyarrow>=13.0.0", "pandas~=2.0.0"],

src/fairseq2/assets/card.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import re
1111
from collections.abc import Mapping, MutableMapping, Set
1212
from pathlib import Path
13-
from typing import Any, Final, Optional, TypeVar, final
13+
from typing import Any, Final, TypeVar, final
1414
from urllib.parse import urlparse, urlunparse
1515

1616
from fairseq2.assets.error import AssetError
@@ -25,10 +25,10 @@ class AssetCard:
2525

2626
_name: str
2727
_metadata: MutableMapping[str, Any]
28-
_base: Optional[AssetCard]
28+
_base: AssetCard | None
2929

3030
def __init__(
31-
self, metadata: MutableMapping[str, Any], base: Optional[AssetCard] = None
31+
self, metadata: MutableMapping[str, Any], base: AssetCard | None = None
3232
) -> None:
3333
"""
3434
:param metadata:
@@ -143,7 +143,7 @@ def metadata(self) -> Mapping[str, Any]:
143143
return self._metadata
144144

145145
@property
146-
def base(self) -> Optional[AssetCard]:
146+
def base(self) -> AssetCard | None:
147147
"""The card that this card derives from."""
148148
return self._base
149149

@@ -187,7 +187,7 @@ def as_(
187187
type_hint: Any,
188188
*,
189189
allow_empty: bool = False,
190-
value_converter: Optional[ValueConverter] = None,
190+
value_converter: ValueConverter | None = None,
191191
set_empty: bool = False,
192192
) -> Any:
193193
"""Return the value of this field.
@@ -297,10 +297,10 @@ def as_filename(self) -> str:
297297
def get_as_(
298298
self,
299299
type_hint: Any,
300-
default: Optional[T] = None,
300+
default: T | None = None,
301301
*,
302302
allow_empty: bool = False,
303-
value_converter: Optional[ValueConverter] = None,
303+
value_converter: ValueConverter | None = None,
304304
set_empty: bool = False,
305305
) -> Any:
306306
"""Return the value of this field if it exists; otherwise, return ``default``.
@@ -331,7 +331,7 @@ def set(
331331
value: Any,
332332
*,
333333
type_hint: Any = None,
334-
value_converter: Optional[ValueConverter] = None,
334+
value_converter: ValueConverter | None = None,
335335
) -> None:
336336
"""Set the value of this field.
337337

src/fairseq2/assets/download_manager.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from shutil import rmtree
1616
from tarfile import TarFile, is_tarfile
1717
from tempfile import NamedTemporaryFile
18-
from typing import Optional, final
18+
from typing import final
1919
from urllib.error import HTTPError, URLError
2020
from urllib.parse import unquote, urlparse
2121
from urllib.request import Request, urlopen
@@ -41,7 +41,7 @@ def download_checkpoint(
4141
uri: str,
4242
model_name: str,
4343
*,
44-
shard_idx: Optional[int] = None,
44+
shard_idx: int | None = None,
4545
force: bool = False,
4646
progress: bool = True,
4747
) -> Path:
@@ -68,7 +68,7 @@ def download_tokenizer(
6868
uri: str,
6969
model_name: str,
7070
*,
71-
tokenizer_name: Optional[str] = None,
71+
tokenizer_name: str | None = None,
7272
force: bool = False,
7373
progress: bool = True,
7474
) -> Path:
@@ -137,7 +137,7 @@ def download_checkpoint(
137137
uri: str,
138138
model_name: str,
139139
*,
140-
shard_idx: Optional[int] = None,
140+
shard_idx: int | None = None,
141141
force: bool = False,
142142
progress: bool = True,
143143
) -> Path:
@@ -158,7 +158,7 @@ def download_tokenizer(
158158
uri: str,
159159
model_name: str,
160160
*,
161-
tokenizer_name: Optional[str] = None,
161+
tokenizer_name: str | None = None,
162162
force: bool = False,
163163
progress: bool = True,
164164
) -> Path:
@@ -191,11 +191,11 @@ class _AssetDownloadOp:
191191
_cache_dir: Path
192192
_uri: str
193193
_uri_params: dict[str, str]
194-
_asset_dir: Optional[Path]
194+
_asset_dir: Path | None
195195
_display_name: str
196196
_force: bool
197197
_progress: bool
198-
_shard_idx: Optional[int]
198+
_shard_idx: int | None
199199

200200
def __init__(
201201
self,
@@ -204,7 +204,7 @@ def __init__(
204204
display_name: str,
205205
force: bool,
206206
progress: bool,
207-
shard_idx: Optional[int] = None,
207+
shard_idx: int | None = None,
208208
) -> None:
209209
self._cache_dir = cache_dir
210210
self._uri = uri
@@ -291,7 +291,7 @@ def _check_if_gated_asset(self) -> None:
291291
f"The {self._display_name} is gated. Please visit {self._uri} to learn how to get access."
292292
)
293293

294-
def _try_uri_as_path(self) -> Optional[Path]:
294+
def _try_uri_as_path(self) -> Path | None:
295295
if self._uri.startswith("file://"):
296296
return Path(unquote(self._uri[7:]))
297297

0 commit comments

Comments
 (0)