Skip to content

Commit

Permalink
Fixed stray reno and added script to check the same (#691)
Browse files Browse the repository at this point in the history
* fixed stray reno

* added script to block stray renos

* header updated

* Apply suggestions from code review

Co-authored-by: Ivan Carvalho <8753214+IvanIsCoding@users.noreply.github.com>
  • Loading branch information
prakharb10 and IvanIsCoding authored Oct 4, 2022
1 parent 51637af commit 63de4cb
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ jobs:
run: black --check --diff retworkx rustworkx retworkx tests
- name: Python Lint
run: flake8 --per-file-ignores='retworkx/__init__.py:F405,F403' setup.py retworkx tests rustworkx
- name: Check stray release notes
run: python tools/find_stray_release_notes.py
- name: rustworkx-core Rust Tests
run: pushd rustworkx-core && cargo test && popd
- name: rustworkx-core Docs
Expand Down
11 changes: 11 additions & 0 deletions releasenotes/notes/0.11/prepare-0.11-af688e532712c830.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ features:
[{'color': 'turquoise', 'size': 'extra large', '__networkx_node__': 'A'}, {'color': 'fuschia', 'size': 'tiny', '__networkx_node__': 'B'}]
WeightedEdgeList[(0, 1, {})]
fixes:
- |
Fixed an issue with the :func:`~retworkx.generators.heavy_hex_graph`,
:func:`~retworkx.generators.directed_heavy_hex_graph`,
:func:`~retworkx.generators.heavy_square_graph`,
and :func:`~retworkx.generators.directed_heavy_square_graph` generator
functions. When the input parameter ``d`` was set to 1 these functions
would previously raise a ``pyo3_runtime.PanicException`` instead of
returning the expected graph (a single node).
Fixed `#452 <https://github.com/Qiskit/retworkx/issues/452>`__

This file was deleted.

53 changes: 53 additions & 0 deletions tools/find_stray_release_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""Utility script to find any stray release notes."""

import argparse
import multiprocessing
import subprocess
import sys
import re

# release notes regex
reno = re.compile(r"releasenotes\/notes")
# exact release note regex
exact_reno = re.compile(r"^releasenotes\/notes")


def discover_files():
"""Find all .py, .pyx, .pxd files in a list of trees"""
cmd = ["git", "ls-tree", "-r", "--name-only", "HEAD"]
res = subprocess.run(cmd, capture_output=True, check=True, encoding="UTF8")
files = res.stdout.split("\n")
return files


def validate_path(file_path):
"""Validate a path in the git tree."""
if reno.search(file_path) and not exact_reno.search(file_path):
return file_path
return None


def _main():
parser = argparse.ArgumentParser(description="Find any stray release notes.")
_args = parser.parse_args()
files = discover_files()
with multiprocessing.Pool() as pool:
res = pool.map(validate_path, files)
failed_files = [x for x in res if x is not None]
if len(failed_files) > 0:
for failed_file in failed_files:
sys.stderr.write("%s is not in the correct location.\n" % failed_file)
sys.exit(1)
sys.exit(0)


if __name__ == "__main__":
_main()
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ commands =
black --check --diff {posargs} '../rustworkx' '../tests' '../retworkx'
flake8 --per-file-ignores='../rustworkx/__init__.py:F405,F403' ../setup.py ../rustworkx ../retworkx .
cargo fmt --all -- --check
python {toxinidir}/tools/find_stray_release_notes.py

[testenv:docs]
basepython = python3
Expand Down

0 comments on commit 63de4cb

Please sign in to comment.