Skip to content

Commit

Permalink
chore: bump Python version (#980)
Browse files Browse the repository at this point in the history
* chore: bump Python version

* remove python 3.7 from ci

* add python 3.11 to matrix build

* add python 3.12

* remove python 3.12

* remove python 3.11 from matrix build (already in vanilla build)

* fix: pull out `.data` from `NumpyArray`

* ci: test 3.12

* fix: don't require aiohttp for 3.12

* ci: fix line breaks

Windows PS1 does not like this.

* fix: deprecated `ast.Str`

* fix: deprecated parameters to HTTPConnection

* fix: check `node.value`

* test: require aiohttp

* fix: `ask.Num` is deprecated

* fix: use `ast.Constant` in return

* style: pre-commit fixes

---------

Co-authored-by: Luis Antonio Obis Aparicio <[email protected]>
Co-authored-by: Jim Pivarski <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 11, 2023
1 parent 6abbdc3 commit 808baf7
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 30 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,7 +70,6 @@ jobs:
runs-on: "${{ matrix.platform }}"
timeout-minutes: 30


steps:
- uses: "actions/checkout@v4"

Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]" },
]
Expand All @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/uproot/_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions src/uproot/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
"""
Expand Down
12 changes: 7 additions & 5 deletions src/uproot/interpretation/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


import ast
import numbers
import re

import numpy
Expand Down Expand Up @@ -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)
):
Expand Down Expand Up @@ -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(
[
Expand Down
11 changes: 8 additions & 3 deletions src/uproot/language/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}; "
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions src/uproot/source/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_0692_fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 808baf7

Please sign in to comment.