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

Update and fix issues raised by Python QA tools #162

Merged
merged 7 commits into from
Jan 12, 2024
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
28 changes: 28 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[flake8]
extend-ignore =
# Line too long
E501
# Whitespace issues
D2
# Quote issues
D3
# Docstring Content Issues
D4
# Missing docstring in public module
D100
# Missing docstring in public package
D104
# Missing docstring in magic method
D105
# Missing docstring in public nested class
D106
# Missing docstring in __init__
D107
# Line break occurred before a binary operator
W503
# Whitespace before ':'
E203
extend-exclude =
tests/**,
docs/**
max-line-length = 119
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,3 @@ Please write the debug information inside <code>```</code> quotes in order to pr

```
```

18 changes: 15 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
- name: Checkout the repository
uses: actions/checkout@v3
- name: Run black
uses: psf/black@stable
with:
src: "./melusine"

pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- name: Run pre-commit
uses: pre-commit/[email protected]

test:
name: Test
needs: lint
Expand All @@ -18,7 +30,7 @@ jobs:
fail-fast: false
max-parallel: 2
matrix:
python-version: ["3.8", "3.10", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout the repository
uses: actions/checkout@v3
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ dmypy.json

# Pytest-env
pytest.ini

# IDEA/Jetbrains
.idea
39 changes: 24 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-byte-order-marker
Expand All @@ -11,7 +11,9 @@ repos:
- id: check-executables-have-shebangs
- id: check-json
- id: check-yaml
exclude: ^chart/
# Ignore mkdocs because the linter fails on the pymdownx specific
# syntax to inject Python code from configuration.
exclude: mkdocs.yml
- id: debug-statements
- id: end-of-file-fixer
exclude: ^(docs/|gdocs/)
Expand All @@ -24,42 +26,49 @@ repos:
args: ['--maxkb=500']
- id: no-commit-to-branch
args: ['--branch', 'master', '--branch', 'develop']

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 23.12.1
hooks:
- id: black
args: [--line-length=120]
additional_dependencies: ['click==8.0.4']

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.931'
rev: 'v1.8.0'
hooks:
- id: mypy
args: [--ignore-missing-imports, --disallow-untyped-defs, --show-error-codes, --no-site-packages]
files: ^melusine

- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.0.0
hooks:
- id: flake8
exclude: '^tests/|^docs'
args: ['--ignore=E501,D2,D3,D4,D104,D100,D106,D107,W503,D105,E203']
additional_dependencies: [ flake8-docstrings, "flake8-bugbear==22.8.23" ]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
hooks:
- id: ruff

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.4.2
rev: v5.10.1
hooks:
- id: isort
args: ["--profile", "black", "-l", "120"]

- repo: https://github.com/asottile/pyupgrade
rev: v2.7.2
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/asottile/blacken-docs
rev: v1.8.0
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==21.12b0]
additional_dependencies: [black>=22.1]

- repo: https://github.com/compilerla/conventional-pre-commit
rev: v2.1.1
rev: v3.0.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
Expand Down
Empty file modified AUTHORS.rst
100755 → 100644
Empty file.
Empty file modified LICENSE
100755 → 100644
Empty file.
Empty file modified MANIFEST.in
100755 → 100644
Empty file.
Empty file modified Makefile
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
4 changes: 2 additions & 2 deletions melusine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Top-level package.
"""
import logging
import pandas as pd

from ctypes import CDLL, cdll
from typing import Any, Optional

import pandas as pd

from melusine._config import config

__all__ = ["config"]
Expand Down
4 changes: 2 additions & 2 deletions melusine/backend/active_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def apply_transform(
**kwargs,
)

def copy(self, data: Any, fields: List[str] = None) -> Any:
def copy(self, data: Any, fields: Optional[List[str]] = None) -> Any:
"""
Method to make a copy of the input dataset.

Expand Down Expand Up @@ -136,7 +136,7 @@ def get_fields(self, data: Any) -> List[str]:
"""
return self.backend.get_fields(data=data)

def add_fields(self, left: Any, right: Any, fields: List[str] = None) -> Any:
def add_fields(self, left: Any, right: Any, fields: Optional[List[str]] = None) -> Any:
"""
Method to add fields from the right object to the left object

Expand Down
4 changes: 2 additions & 2 deletions melusine/backend/base_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def apply_transform(
"""

@abstractmethod
def add_fields(self, left: Any, right: Any, fields: List[str] = None) -> Any:
def add_fields(self, left: Any, right: Any, fields: Optional[List[str]] = None) -> Any:
"""
Method to add fields form the right object to the left object.

Expand All @@ -71,7 +71,7 @@ def add_fields(self, left: Any, right: Any, fields: List[str] = None) -> Any:
"""

@abstractmethod
def copy(self, data: Any, fields: List[str] = None) -> Any:
def copy(self, data: Any, fields: Optional[List[str]] = None) -> Any:
"""
Method to make a copy of the dataset.

Expand Down
6 changes: 4 additions & 2 deletions melusine/backend/dict_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def apply_transform(

return data

def add_fields(self, left: Dict[str, Any], right: Dict[str, Any], fields: List[str] = None) -> Dict[str, Any]:
def add_fields(
self, left: Dict[str, Any], right: Dict[str, Any], fields: Optional[List[str]] = None
) -> Dict[str, Any]:
"""
Method to add fields form the right object to the left object.

Expand All @@ -106,7 +108,7 @@ def add_fields(self, left: Dict[str, Any], right: Dict[str, Any], fields: List[s

return left

def copy(self, data: Dict[str, Any], fields: List[str] = None) -> Dict[str, Any]:
def copy(self, data: Dict[str, Any], fields: Optional[List[str]] = None) -> Dict[str, Any]:
"""
Method to make a copy of the dataset.

Expand Down
8 changes: 4 additions & 4 deletions melusine/backend/pandas_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def apply_transform_multiprocessing(
def apply_joblib_dataframe(
df: pd.DataFrame,
func: Callable,
expand: str = None,
expand: Optional[str] = None,
progress_bar: bool = False,
**kwargs: Any,
) -> pd.DataFrame:
Expand All @@ -260,7 +260,7 @@ def apply_joblib_dataframe(
def apply_joblib_series(
s: pd.Series,
func: Callable,
expand: str = None,
expand: Optional[str] = None,
progress_bar: bool = False,
**kwargs: Any,
) -> pd.DataFrame:
Expand All @@ -280,7 +280,7 @@ def apply_joblib_series(

return result

def add_fields(self, left: pd.DataFrame, right: pd.DataFrame, fields: List[str] = None) -> pd.DataFrame:
def add_fields(self, left: pd.DataFrame, right: pd.DataFrame, fields: Optional[List[str]] = None) -> pd.DataFrame:
"""
Method to add fields form the right object to the left object.

Expand All @@ -302,7 +302,7 @@ def add_fields(self, left: pd.DataFrame, right: pd.DataFrame, fields: List[str]

return left

def copy(self, data: pd.DataFrame, fields: List[str] = None) -> pd.DataFrame:
def copy(self, data: pd.DataFrame, fields: Optional[List[str]] = None) -> pd.DataFrame:
"""
Method to make a copy of the dataset.

Expand Down
Loading