diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index f7fd78e76..83a86d9b6 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -16,10 +16,7 @@ jobs: fail-fast: false matrix: platform: ["windows-latest", "macos-latest", "ubuntu-latest"] - python-version: ["3.7", "3.8", "3.9", "3.10"] - exclude: - - platform: "windows-latest" - python-version: "3.7" + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: "${{ matrix.platform }}" timeout-minutes: 30 @@ -73,7 +70,6 @@ jobs: runs-on: "${{ matrix.platform }}" timeout-minutes: 30 - steps: - uses: "actions/checkout@v4" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3f167b2e5..16347ae46 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,3 +27,10 @@ repos: hooks: - id: ruff args: ["--fix", "--show-fixes"] + + +- repo: https://github.com/asottile/pyupgrade + rev: v3.13.0 + hooks: + - id: pyupgrade + args: ["--py38-plus"] diff --git a/pyproject.toml b/pyproject.toml index 89c4667db..d7ae3aa8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ name = "uproot" description = "ROOT I/O in pure Python and NumPy." readme = "README.md" license = "BSD-3-Clause" -requires-python = ">=3.7" +requires-python = ">=3.8" authors = [ { name = "Jim Pivarski", email = "pivarski@princeton.edu" }, ] @@ -25,11 +25,11 @@ classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Scientific/Engineering :: Mathematics", @@ -51,16 +51,16 @@ dynamic = [ [project.optional-dependencies] dev = [ "boost_histogram>=0.13", - "dask-awkward>=2023.10.0a1;python_version >= \"3.8\"", - "dask[array];python_version >= \"3.8\"", + "dask-awkward>=2023.9.0", + "dask[array]", "hist>=1.2", "pandas", - "awkward-pandas;python_version >= \"3.8\"", + "awkward-pandas", ] test = [ "lz4", "minio", - "aiohttp", + "aiohttp; python_version<\"3.12\"", "fsspec", "fsspec-xrootd", "pytest>=6", diff --git a/src/uproot/_dask.py b/src/uproot/_dask.py index 21009ee52..2a2a11f62 100644 --- a/src/uproot/_dask.py +++ b/src/uproot/_dask.py @@ -4,9 +4,9 @@ from collections.abc import Callable, Iterable, Mapping try: - from typing import TYPE_CHECKING + from typing import TYPE_CHECKING, Final - from typing_extensions import Any, Final, Protocol, TypeVar + from typing_extensions import Any, Protocol, TypeVar except ImportError: from typing import TYPE_CHECKING, Any, Final, Protocol, TypeVar diff --git a/src/uproot/extras.py b/src/uproot/extras.py index 39b6e8c18..cf26d7510 100644 --- a/src/uproot/extras.py +++ b/src/uproot/extras.py @@ -10,16 +10,11 @@ import atexit +import importlib.metadata as importlib_metadata import os -import sys from uproot._util import parse_version -if sys.version_info < (3, 8): - import importlib_metadata -else: - import importlib.metadata as importlib_metadata - def awkward(): """ diff --git a/src/uproot/interpretation/identify.py b/src/uproot/interpretation/identify.py index 13c50751d..1be3bdb79 100644 --- a/src/uproot/interpretation/identify.py +++ b/src/uproot/interpretation/identify.py @@ -14,6 +14,7 @@ import ast +import numbers import re import numpy @@ -164,15 +165,15 @@ def _float16_double32_walk_ast(node, branch, source): and isinstance(node.ctx, ast.Load) and node.id.lower() == "pi" ): - out = ast.Num(3.141592653589793) # TMath::Pi() + out = ast.Constant(3.141592653589793) # TMath::Pi() elif ( isinstance(node, ast.Name) and isinstance(node.ctx, ast.Load) and node.id.lower() == "twopi" ): - out = ast.Num(6.283185307179586) # TMath::TwoPi() - elif isinstance(node, ast.Num): - out = ast.Num(float(node.n)) + out = ast.Constant(6.283185307179586) # TMath::TwoPi() + elif isinstance(node, ast.Constant) and isinstance(node.value, numbers.Number): + out = ast.Constant(float(node.value)) elif isinstance(node, ast.BinOp) and isinstance( node.op, (ast.Add, ast.Sub, ast.Mult, ast.Div) ): @@ -201,7 +202,8 @@ def _float16_double32_walk_ast(node, branch, source): isinstance(node, ast.List) and isinstance(node.ctx, ast.Load) and len(node.elts) == 3 - and isinstance(node.elts[2], ast.Num) + and isinstance(node.elts[2], ast.Constant) + and isinstance(node.elts[2].value, numbers.Number) ): out = ast.List( [ diff --git a/src/uproot/language/python.py b/src/uproot/language/python.py index 61ddcb751..8c0085ae6 100644 --- a/src/uproot/language/python.py +++ b/src/uproot/language/python.py @@ -57,8 +57,12 @@ def _walk_ast_yield_symbols(node, keys, aliases, functions, getter): and isinstance(node.func, ast.Name) and node.func.id == getter ): - if len(node.args) == 1 and isinstance(node.args[0], ast.Str): - yield node.args[0].s + if ( + len(node.args) == 1 + and isinstance(node.args[0], ast.Constant) + and isinstance(node.args[0].value, str) + ): + yield node.args[0].value else: raise TypeError( f"expected a constant string as the only argument of {getter!r}; " @@ -104,7 +108,8 @@ def _ast_as_branch_expression(node, keys, aliases, functions, getter): and isinstance(node.func, ast.Name) and node.func.id == getter and len(node.args) == 1 - and isinstance(node.args[0], ast.Str) + and isinstance(node.args[0], ast.Constant) + and isinstance(node.args[0].value, str) ): return node diff --git a/src/uproot/source/http.py b/src/uproot/source/http.py index 6278e0733..ecfd6d135 100644 --- a/src/uproot/source/http.py +++ b/src/uproot/source/http.py @@ -39,9 +39,7 @@ def make_connection(parsed_url, timeout): from http.client import HTTPConnection, HTTPSConnection if parsed_url.scheme == "https": - return HTTPSConnection( - parsed_url.hostname, parsed_url.port, None, None, timeout - ) + return HTTPSConnection(parsed_url.hostname, parsed_url.port, timeout=timeout) elif parsed_url.scheme == "http": return HTTPConnection(parsed_url.hostname, parsed_url.port, timeout) diff --git a/tests/test_0692_fsspec.py b/tests/test_0692_fsspec.py index e9c6adacf..eb6dd08c8 100644 --- a/tests/test_0692_fsspec.py +++ b/tests/test_0692_fsspec.py @@ -10,6 +10,8 @@ @pytest.mark.network def test_open_fsspec_http(): + pytest.importorskip("aiohttp") + with uproot.open( "https://github.com/scikit-hep/scikit-hep-testdata/raw/v0.4.33/src/skhep_testdata/data/uproot-issue121.root", http_handler=uproot.source.fsspec.FSSpecSource,