Skip to content

Commit

Permalink
Add mypy and pytest-cov
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardobranco777 committed Aug 12, 2023
1 parent dff68b7 commit 8afdb82
Show file tree
Hide file tree
Showing 13 changed files with 113 additions and 70 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,22 @@ jobs:
- name: test
run: |
make test
- name: mypy
run: |
make mypy
run:
runs-on: ubuntu-latest
name: codecov
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: pip install -r requirements-test.txt
- name: Run tests and collect coverage
run: make pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/*.pyc
**/__pycache__
.coverage
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MESSAGES CONTROL]
disable=invalid-name,global-statement,too-many-ancestors,too-few-public-methods,too-many-public-methods,missing-function-docstring,missing-module-docstring,missing-class-docstring
disable=invalid-name,too-many-ancestors,too-few-public-methods,too-many-public-methods,missing-function-docstring,missing-module-docstring,missing-class-docstring
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FILES = restartable ldpreload */*.py

.PHONY: all
all: flake8 pylint test
all: flake8 pylint test pytest mypy

.PHONY: flake8
flake8:
Expand All @@ -11,6 +11,16 @@ flake8:
pylint:
@pylint --disable=line-too-long $(FILES)

.PHONY: pytest
pytest:
@TZ=UTC LC_ALL=en_US.UTF-8 pytest -vv --cov

.PHONY: mypy
mypy:
@mypy */*.py
@mypy restartable
@mypy ldpreload

.PHONY: test
test:
@TZ=UTC LC_ALL=en_US.UTF-8 python3 -m unittest tests/*.py
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Similar libraries but lacking this functionality:
- https://github.com/giampaolo/psutil
- https://github.com/pmuller/procfs

## Installation

Add `https://github.com/ricardobranco777/linux-procfs/archive/master.zip` to `requirements.txt` or run:

`pip install --user https://github.com/ricardobranco777/linux-procfs/archive/master.zip`

## NOTES

- Tested on Python 3.8+
2 changes: 1 addition & 1 deletion ldpreload
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import sys
from procfs.procfs import Proc, ProcPid


def print_info(proc, lines):
def print_info(proc, lines: list[str]) -> None:
"Print info"
print("{:<8} {:<16} {}".format(
proc.pid, os.path.basename(proc.cmdline[0]), "\n".join(lines)))
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
disable_error_code = attr-defined

0 comments on commit 8afdb82

Please sign in to comment.