Skip to content

Commit

Permalink
Add pylint as part of CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bonicim committed Oct 4, 2022
1 parent 24245fd commit b53eb48
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
with:
python-version: ${{ matrix.python }}

- name: Install Pylint
run: pip install pylint

# https://github.com/pre-commit/action
- name: Run pre-commit hooks
uses: pre-commit/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ venv*
.idea
env
.venv*
pylint-results.txt
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ repos:
- id: mypy
exclude: (?x)(docs/|tests/)
args: [--no-strict-optional, --ignore-missing-imports]

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"--rcfile=.pylintrc",
"--exit-zero" # Always return a 0 (non-error) status code, even if lint errors are found. This is primarily useful in continuous integration scripts.
]
13 changes: 13 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[MAIN]

# Specify a score threshold under which the program will exit with error.
fail-under=5.86

[REPORTS]
# Tells whether to display a full report or only the messages.
reports=yes

# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
output-format=colorized
64 changes: 56 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ HyperNetX
=========
![Passing?](https://github.com/pnnl/HyperNetX/actions/workflows/ci.yml/badge.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![linting: pylint](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)

The HNX library provides classes and methods for modeling the entities and relationships
found in complex networks as hypergraphs, the natural models for multi-dimensional network data.
Expand Down Expand Up @@ -234,8 +235,8 @@ License
Released under the 3-Clause BSD license (see License.rst)


Continuous Integration/Continuous Deployment
--------------------------------------------
Continuous Integration
----------------------

This project runs Continuous Integration (CI) using GitHub Actions. Normally, CI runs
on pull requests, pushes to certain branches, and other events.
Expand All @@ -253,12 +254,8 @@ gh workflow run ci.yml --repo pnnl/HyperNetX --ref <name of branch that you want
gh run list --workflow=ci.yml --repo pnnl/HyperNetX
```


Development
-----------

Continuous Integration/Continuous Deployment
--------------------------------------------
Versioning
----------

Versioning is automated using [bump2version](https://pypi.org/project/bump2version/).
To automatically update the version when preparing a release, run the following commands:
Expand All @@ -268,3 +265,54 @@ To automatically update the version when preparing a release, run the following
make bump-version-<part>
make commit-docs
```


# Development

## Code Quality

HyperNetX uses a number of tools to maintain code quality:

* Pylint
* Black

### Pylint

[Pylint](https://pylint.pycqa.org/en/latest/index.html) is a static code analyzer for Python-based projects. From the [Pylint docs](https://pylint.pycqa.org/en/latest/index.html#what-is-pylint):

> Pylint analyses your code without actually running it. It checks for errors, enforces a coding standard, looks for code smells, and can make suggestions about how the code could be refactored. Pylint can infer actual values from your code using its internal code representation (astroid). If your code is import logging as argparse, Pylint will know that argparse.error(...) is in fact a logging call and not an argparse call.
Before using this tool, ensure that you install Pylint in your environment:

```commandline
pip install -e .['auto-testing']
```

We have a Pylint configuration file, `.pylintrc`, located at the root of this project.
To run Pylint and view the results of Pylint, run the following command:

```commandline
pylint hypernetx --rcfile=.pylintrc
```

You can also run Pylint on the command line to generate a report on the quality of the codebase and save it to a file named "pylint-results.txt":

```commandline
pylint hypernetx --output=pylint-results.txt
```

For more information on configuration, see https://pylint.pycqa.org/en/latest/user_guide/configuration/index.html

### Black

[Black](https://black.readthedocs.io/en/stable/) is a PEP 8 compliant formatter for Python-based project. This tool is highly opinionated about how Python should be formatted and will automagically reformat your code.

Before using this tool, ensure that you install Pylint in your environment:

```commandline
pip install -e .['auto-testing']
```

```commandline
black hypernetx
```
4 changes: 2 additions & 2 deletions cicd/push-release-tag-ghub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ git checkout "${current_tag}"
echo "${current_tag}" > tempbranch.txt
cat tempbranch.txt

# log the branch, remotes, and last commit for forsensics
# log the branch, remotes, and last commit for forensics
git branch -vv
git remote -vv
git --no-pager show --name-only
Expand All @@ -30,7 +30,7 @@ git --no-pager show --name-only
# to access the HyperNetX Github repo
git remote add gh-origin "https://${bamboo.GITHUB_USERNAME}:${bamboo.GHUB_PAT_PASSWORD}@github.com/pnnl/HyperNetX.git"

# log the remotes for forsensics
# log the remotes for forensics
git remote -vv

# Push the latest tag branch to HyperNetX repo on Github
Expand Down
35 changes: 0 additions & 35 deletions mypy.ini

This file was deleted.

43 changes: 40 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,44 @@ allow_dirty = True

[bumpversion:file:setup.py]


[mypy-setup.py]
ignore_errors = True

[mypy]
python_version = 3.7
exclude = (?x)(
tests/ # test directory
)
pretty = True

# Per-module options:
[mypy-igraph]
ignore_missing_imports = True

[mypy-decorator]
ignore_missing_imports = True

[mypy-celluloid]
ignore_missing_imports = True

[mypy-matplotlib.*]
ignore_missing_imports = True

[mypy-networkx.*]
ignore_missing_imports = True

[mypy-sklearn.*]
ignore_missing_imports = True

[mypy-scipy.*]
ignore_missing_imports = True

[mypy-nwhy]
ignore_missing_imports = True

[mypy-pandas]
ignore_missing_imports = True

[metadata]
python_requires = '>=3.7'
description_file = README.md
Expand Down Expand Up @@ -51,8 +85,11 @@ install_requires =
releases =
bump2version>=1.0.1
auto-testing =
tox>=3.25.1
pre-commit>=2.20.0
tox>=3.25.1
pre-commit>=2.20.0
pylint>=2.15.3
pylint-exit>=1.2.0
black>=22.8.0
testing =
pytest>=4.0
pytest-cov>=3.0.0
Expand Down

0 comments on commit b53eb48

Please sign in to comment.