Skip to content

Commit 0e55857

Browse files
kratsgmatthewfeickert
authored andcommitted
build: Drop Python 3.8 support
1 parent 2320c9c commit 0e55857

File tree

18 files changed

+36
-76
lines changed

18 files changed

+36
-76
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
strategy:
3131
matrix:
3232
os: [ubuntu-latest]
33-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
33+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
3434
include:
3535
- os: macos-latest
3636
python-version: '3.13'

.github/workflows/lower-bound-requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
matrix:
1818
os: [ubuntu-latest]
1919
# minimum supported Python
20-
python-version: ['3.8']
20+
python-version: ['3.9']
2121

2222
steps:
2323
- uses: actions/checkout@v5

.github/workflows/release_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
strategy:
2323
matrix:
2424
os: [ubuntu-latest]
25-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
25+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
2626
include:
2727
- os: macos-latest
2828
python-version: '3.13'

.pre-commit-config.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ repos:
5555
- repo: https://github.com/pre-commit/mirrors-mypy
5656
rev: v1.13.0
5757
# check the oldest and newest supported Pythons
58+
# except skip python 3.9 for numpy, due to poor typing
5859
hooks:
5960
- &mypy
6061
id: mypy
61-
name: mypy with Python 3.8
62+
name: mypy with Python 3.10
6263
files: src
6364
additional_dependencies:
6465
['numpy', 'types-tqdm', 'click', 'types-jsonpatch', 'types-pyyaml', 'types-jsonschema', 'importlib_metadata', 'packaging']
65-
args: ["--python-version=3.8"]
66+
args: ["--python-version=3.10"]
6667
- <<: *mypy
6768
name: mypy with Python 3.13
6869
args: ["--python-version=3.13"]

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dynamic = ["version"]
1111
description = "pure-Python HistFactory implementation with tensors and autodiff"
1212
readme = "README.rst"
1313
license = "Apache-2.0"
14-
requires-python = ">=3.8"
14+
requires-python = ">=3.9"
1515
authors = [
1616
{ name = "Lukas Heinrich", email = "[email protected]" },
1717
{ name = "Matthew Feickert", email = "[email protected]" },
@@ -32,7 +32,6 @@ classifiers = [
3232
"Operating System :: OS Independent",
3333
"Programming Language :: Python :: 3",
3434
"Programming Language :: Python :: 3 :: Only",
35-
"Programming Language :: Python :: 3.8",
3635
"Programming Language :: Python :: 3.9",
3736
"Programming Language :: Python :: 3.10",
3837
"Programming Language :: Python :: 3.11",

src/pyhf/contrib/utils.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,7 @@ def download(archive_url, output_directory, force=False, compress=False):
8080
with open(output_directory, "wb") as archive:
8181
archive.write(response.content)
8282
else:
83-
# Support for file-like objects for tarfile.is_tarfile was added
84-
# in Python 3.9, so as pyhf is currently Python 3.8+ then can't
85-
# do tarfile.is_tarfile(BytesIO(response.content)).
86-
# Instead, just use a 'try except' block to determine if the
87-
# archive is a valid tarfile.
88-
# TODO: Simplify after pyhf is Python 3.9+ only
89-
try:
83+
if tarfile.is_tarfile(BytesIO(response.content)):
9084
# Use transparent compression to allow for .tar or .tar.gz
9185
with tarfile.open(
9286
mode="r:*", fileobj=BytesIO(response.content)
@@ -97,13 +91,7 @@ def download(archive_url, output_directory, force=False, compress=False):
9791
archive.extractall(output_directory, filter="data")
9892
else:
9993
archive.extractall(output_directory)
100-
except tarfile.ReadError:
101-
if not zipfile.is_zipfile(BytesIO(response.content)):
102-
raise exceptions.InvalidArchive(
103-
f"The archive downloaded from {archive_url} is not a tarfile"
104-
+ " or a zipfile and so can not be opened as one."
105-
)
106-
94+
elif zipfile.is_zipfile(BytesIO(response.content)):
10795
output_directory = Path(output_directory)
10896
if output_directory.exists():
10997
rmtree(output_directory)
@@ -129,6 +117,11 @@ def download(archive_url, output_directory, force=False, compress=False):
129117
# from creation time
130118
rmtree(output_directory)
131119
_tmp_path.replace(output_directory)
120+
else:
121+
raise exceptions.InvalidArchive(
122+
f"The archive downloaded from {archive_url} is not a tarfile"
123+
+ " or a zipfile and so can not be opened as one."
124+
)
132125

133126
except ModuleNotFoundError:
134127
log.error(

src/pyhf/mixins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import Any, Sequence
4+
from typing import Any
5+
from collections.abc import Sequence
56

67
from pyhf.typing import Channel
78

src/pyhf/modifiers/staterror.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
from typing import List
32

43
import pyhf
54
from pyhf import events
@@ -10,7 +9,7 @@
109
log = logging.getLogger(__name__)
1110

1211

13-
def required_parset(sigmas, fixed: List[bool]):
12+
def required_parset(sigmas, fixed: list[bool]):
1413
n_parameters = len(sigmas)
1514
return {
1615
'paramset_type': 'constrained_by_normal',

src/pyhf/parameters/paramsets.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import List
2-
31
import pyhf
42

53
__all__ = [
@@ -29,7 +27,7 @@ def __init__(self, **kwargs):
2927
)
3028

3129
@property
32-
def suggested_fixed(self) -> List[bool]:
30+
def suggested_fixed(self) -> list[bool]:
3331
if isinstance(self._suggested_fixed, bool):
3432
return [self._suggested_fixed] * self.n_parameters
3533
return self._suggested_fixed

src/pyhf/pdf.py

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

33
import copy
44
import logging
5-
from typing import List, Union
5+
from typing import Union
66

77
import pyhf.parameters
88
import pyhf
@@ -406,7 +406,7 @@ def param_set(self, name):
406406
"""
407407
return self.par_map[name]['paramset']
408408

409-
def suggested_fixed(self) -> List[bool]:
409+
def suggested_fixed(self) -> list[bool]:
410410
"""
411411
Identify the fixed parameters in the model.
412412

0 commit comments

Comments
 (0)