Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use ruff to import annotations #1042

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
rev: v0.1.6
hooks:
- id: ruff
args: [--fix, --show-fixes]
Expand Down
1 change: 1 addition & 0 deletions dev/example-objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Use this to make an example ROOT file for src/uproot/models/TH.py and src/uproot/models/TGraph.py.
"""
from __future__ import annotations

import numpy as np
import ROOT
Expand Down
1 change: 1 addition & 0 deletions dev/make-models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Use this to make src/uproot/models/TH.py and src/uproot/models/TGraph.py.
"""
from __future__ import annotations

import numpy as np

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ select = [
]
src = ["src"]

[tool.ruff.lint]
isort.required-imports = ["from __future__ import annotations"]

[tool.ruff.mccabe]
max-complexity = 100

Expand Down
1 change: 1 addition & 0 deletions src/uproot/_awkward_forth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module defines utilities for adding components to the forth reader.
"""
from __future__ import annotations

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Behaviors are defined by specially named classes in specially named modules
that get auto-detected by :doc:`uproot.behavior.behavior_of`.
"""

from __future__ import annotations

import pkgutil

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/RooCurve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behaviors of ``RooCurve``.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/RooHist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behaviors of ``RooHist``.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TAxis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behaviors of ``TAxis``, an axis of a histogram or profile plot.
"""

from __future__ import annotations

import numpy

Expand Down
1 change: 1 addition & 0 deletions src/uproot/behaviors/TBranch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
See :doc:`uproot.models.TBranch` for deserialization of the ``TBranch``
objects themselves.
"""
from __future__ import annotations

import queue
import re
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TBranchElement.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module defines the behaviors of ``TBranchElement``, which is entirely inherited from
functions in :doc:`uproot.behaviors.TBranch.TBranch`.
"""

from __future__ import annotations

import uproot

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TDatime.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behaviors of ``TDatime``.
"""

from __future__ import annotations

import uproot

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behaviors of ``TGraph``.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TGraphAsymmErrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behaviors of ``TGraphAsymmErrors``.
"""

from __future__ import annotations

import numpy

Expand Down
1 change: 1 addition & 0 deletions src/uproot/behaviors/TGraphErrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module defines the behaviors of ``TGraphErrors``.
"""
from __future__ import annotations


class TGraphErrors:
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TH1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module defines the behaviors of ``TH1`` and its subclasses (not including ``TH2``,
``TH3``, or ``TProfile``).
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TH2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module defines the behaviors of ``TH2`` and its subclasses (not including
``TProfile2D`` and ``TH2Poly``).
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TH2Poly.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behavior of ``TH2Poly``.
"""

from __future__ import annotations

import uproot

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TH3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module defines the behaviors of ``TH3`` and its subclasses (not including
``TProfile3D``).
"""

from __future__ import annotations

import numpy

Expand Down
1 change: 1 addition & 0 deletions src/uproot/behaviors/TParameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module defines the behavior of ``TParameter<T>``.
"""
from __future__ import annotations


class TParameter_3c_boolean_3e_:
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TProfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behavior of ``TProfile``.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TProfile2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behavior of ``TProfile2D``.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TProfile3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines the behavior of ``TProfile3D``.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/behaviors/TTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This module defines the behaviors of ``TTree``, which is almost entirely inherited from
functions in :doc:`uproot.behaviors.TBranch`.
"""

from __future__ import annotations

import uproot

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
The :doc:`uproot.cache.LRUArrayCache` implements the same policy, limiting the
total number of bytes, as reported by ``nbytes``.
"""

from __future__ import annotations

import threading
from collections.abc import MutableMapping
Expand Down
1 change: 1 addition & 0 deletions src/uproot/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module defines integer constants used by serialization and deserialization routines.
"""
from __future__ import annotations

import struct

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

See :doc:`uproot.interpretation` and :doc:`uproot.model`.
"""

from __future__ import annotations

import json
import struct
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/deserialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:doc:`uproot.deserialization.read_object_any`, which manages references to
previously read objects.
"""

from __future__ import annotations

import struct
import sys
Expand Down
1 change: 1 addition & 0 deletions src/uproot/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
classes, which are used as a container in which data from pickled
:doc:`uproot.model.VersionedModel` instances are filled.
"""
from __future__ import annotations


def __getattr__(name):
Expand Down
1 change: 1 addition & 0 deletions src/uproot/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This module defines Uproot-specific exceptions, such as
:doc:`uproot.exceptions.KeyInFileError`.
"""
from __future__ import annotations

import uproot

Expand Down
1 change: 1 addition & 0 deletions src/uproot/extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
If a library cannot be imported, these functions raise ``ModuleNotFoundError`` with
error messages containing instructions on how to install the library.
"""
from __future__ import annotations

import atexit
import importlib.metadata as importlib_metadata
Expand Down
1 change: 1 addition & 0 deletions src/uproot/interpretation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
that determine the default interpretation of a
:doc:`uproot.behaviors.TBranch.TBranch`.
"""
from __future__ import annotations


class Interpretation:
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/interpretation/grouped.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
temporary array for grouped data; usually applied to a ``TBranch`` that does
not contain data but has subbranches that do.
"""

from __future__ import annotations

import uproot

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/interpretation/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
observed in ROOT files (perhaps forever), unless a systematic study can be
performed to exhaustively discover all cases.
"""

from __future__ import annotations

import ast
import numbers
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/interpretation/jagged.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
an array is being built from ``TBaskets``. Its final form is determined by
:doc:`uproot.interpretation.library`.
"""

from __future__ import annotations

import numpy

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/interpretation/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Lazy arrays (:doc:`uproot.behaviors.TBranch.lazy`) can only use the
:doc:`uproot.interpretation.library.Awkward` library.
"""

from __future__ import annotations

import gc
import json
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/interpretation/numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* :doc:`uproot.interpretation.numerical.AsSTLBits`: an ``std::bitset<N>``
for some ``N``.
"""

from __future__ import annotations

import numpy

Expand Down
1 change: 1 addition & 0 deletions src/uproot/interpretation/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
while an array is being built from ``TBaskets``. Its final form is determined
by the :doc:`uproot.interpretation.library.Library`.
"""
from __future__ import annotations

import contextlib
import threading
Expand Down
1 change: 1 addition & 0 deletions src/uproot/interpretation/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
an array is being built from ``TBaskets``. Its final form is determined by the
:doc:`uproot.interpretation.library.Library`.
"""
from __future__ import annotations

import struct
import threading
Expand Down
1 change: 1 addition & 0 deletions src/uproot/language/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

All languages must be subclasses of :doc:`uproot.language.Language`.
"""
from __future__ import annotations


class Language:
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/language/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
The :doc:`uproot.language.python.PythonLanguage` evaluates Python code. It is
the default language.
"""

from __future__ import annotations

import ast
import warnings
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
not be modeled, either because the class has no streamer or no streamer for its
version.
"""

from __future__ import annotations

import re
import sys
Expand Down
1 change: 1 addition & 0 deletions src/uproot/models/RNTuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
This module defines a versionless model for ``ROOT::Experimental::RNTuple``.
"""
from __future__ import annotations

import struct
import zlib
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/models/TArray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines versionless models for ``TArray`` and its subclasses.
"""

from __future__ import annotations

import struct
from collections.abc import Sequence
Expand Down
2 changes: 1 addition & 1 deletion src/uproot/models/TAtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
This module defines versioned models for ``TAttLine``, ``TAttFill``, and ``TAttMarker``.
"""

from __future__ import annotations

import struct

Expand Down
2 changes: 1 addition & 1 deletion src/uproot/models/TBasket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Includes both "embedded" ``TBaskets`` (as a member of TBranch) and "free"
``TBaskets`` (top-level objects, located by ``TKeys``).
"""

from __future__ import annotations

import struct

Expand Down
Loading