Skip to content

Commit

Permalink
Remove pin on Pylint to support Python 3.11
Browse files Browse the repository at this point in the history
* pylintrc and tests/pylintrc generated with Pylint 3.1.0 by running
  "pylint --generate-rcfile" in a Python 3.11 virtual environment.
* Tweaked code and "pylintrc" files so that Pylint checks all pass.
* Add Python 3.11 and ROOT 6.30 to matrix in tests.yml.
* Skip Pylint step in CI for Python 3.6 and Python 3.7.
* ROOT binary built with Python 3.12 not yet supported by Micromamba.
* Closes #234.
  • Loading branch information
GraemeWatt committed Mar 28, 2024
1 parent eb392fe commit 08b563c
Show file tree
Hide file tree
Showing 12 changed files with 1,049 additions and 858 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,31 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
root-version: ["6.24", "6.26", "6.28"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
root-version: ["6.24", "6.26", "6.28", "6.30"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
exclude:
- root-version: "6.24"
python-version: "3.10"
- root-version: "6.24"
python-version: "3.11"
- root-version: "6.26"
python-version: "3.6"
- root-version: "6.26"
python-version: "3.7"
- root-version: "6.26"
python-version: "3.11"
- root-version: "6.28"
python-version: "3.6"
- root-version: "6.28"
python-version: "3.7"
- root-version: "6.30"
python-version: "3.6"
- root-version: "6.30"
python-version: "3.7"
include:
- os: macos-latest
root-version: "6.28"
python-version: "3.10"
root-version: "6.30"
python-version: "3.11"

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -70,7 +78,7 @@ jobs:
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade \
'pylint==2.9.6' \
'pylint' \
pytest_pylint \
configparser \
astroid \
Expand Down Expand Up @@ -109,7 +117,7 @@ jobs:
path: examples/*.html

- name: Run pylint
if: ${{ always() }}
if: ${{ always() && !startsWith(matrix.python-version, '3.6') && !startsWith(matrix.python-version, '3.7') }}
run: |
python -m pylint hepdata_lib/*.py
python -m pylint tests/*.py --rcfile=tests/pylintrc
3 changes: 2 additions & 1 deletion docs/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ Analysing the code
pylint hepdata_lib/*.py
pylint tests/*.py --rcfile=tests/pylintrc

These commands are run by GitHub Actions, so you should first check locally that no issues are flagged.
These commands are run by GitHub Actions (for Python 3.8 or later),
so you should first check locally that no issues are flagged.


Making a release
Expand Down
5 changes: 0 additions & 5 deletions hepdata_lib/c_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def get_graphs(self):

def create_tgraph_dict(self, graph_list, list_of_tgraphs):
"""Function to create pyroot TGraph dict"""
# pylint: disable=no-self-use

# Adding tgraphs into a dictionary
y_values = []
Expand All @@ -100,7 +99,6 @@ def create_tgraph_dict(self, graph_list, list_of_tgraphs):

def create_tgrapherrors_dict(self, graph_list):
"""Function to create pyroot TGraphErrors dict"""
# pylint: disable=no-self-use

# Adding TGraphErrors into a dictionary
y_values = []
Expand Down Expand Up @@ -135,7 +133,6 @@ def create_tgrapherrors_dict(self, graph_list):

def create_tgrapherrors(self, x_value, y_value, dx_value, dy_value):
"""Function to create pyroot TGraphErrors object"""
# pylint: disable=no-self-use

# Creating pyroot TGraphErrors object
x_values = array('i')
Expand Down Expand Up @@ -171,7 +168,6 @@ def create_tgrapherrors(self, x_value, y_value, dx_value, dy_value):

def create_tgraph(self, x_value, y_value):
"""Function to create pyroot TGraph object"""
# pylint: disable=no-self-use

# Creating pyroot TGraph object
x_values = array('i')
Expand All @@ -197,7 +193,6 @@ def create_tgraph(self, x_value, y_value):

def check_for_comments(self, line):
"""Check line for comment"""
# pylint: disable=no-self-use

_line = line
ignoreline = 0
Expand Down
16 changes: 8 additions & 8 deletions hepdata_lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def execute_command(command):
:type command: string
"""

subprocess_args = dict(
args=command,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
universal_newlines=True
)
subprocess_args = {
"args": command,
"stdin": subprocess.PIPE,
"stdout": subprocess.PIPE,
"stderr": subprocess.PIPE,
"shell": True,
"universal_newlines": True
}
with subprocess.Popen(**subprocess_args) as proc:
exit_code = proc.wait()
if exit_code == 127:
Expand Down
4 changes: 2 additions & 2 deletions hepdata_lib/root_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def get_hist_2d_points(hist, **kwargs):
ixmax = hist.GetXaxis().FindBin(xlim[1]) if xlim[1] is not None else hist.GetNbinsX() + 1
iymin = hist.GetYaxis().FindBin(ylim[0]) if ylim[0] is not None else 1
iymax = hist.GetYaxis().FindBin(ylim[1]) if ylim[1] is not None else hist.GetNbinsY() + 1
symmetric = (hist.GetBinErrorOption() == r.TH1.kNormal)
symmetric = hist.GetBinErrorOption() == r.TH1.kNormal
if force_symmetric_errors:
symmetric = True
for x_bin in range(ixmin, ixmax):
Expand Down Expand Up @@ -388,7 +388,7 @@ def get_hist_1d_points(hist, **kwargs):
for key in ["x", "y", "x_edges", "x_labels", "dy"]:
points[key] = []

symmetric = (hist.GetBinErrorOption() == r.TH1.kNormal)
symmetric = hist.GetBinErrorOption() == r.TH1.kNormal
if force_symmetric_errors:
symmetric = True
ixmin = hist.GetXaxis().FindBin(xlim[0]) if xlim[0] is not None else 1
Expand Down
Loading

0 comments on commit 08b563c

Please sign in to comment.