Skip to content

Commit

Permalink
Merge pull request #68 from biomarkersParkinson/typechecking
Browse files Browse the repository at this point in the history
Introduce type checking with pytype
  • Loading branch information
vedran-kasalica authored Mar 11, 2024
2 parents b503c4c + 5c78bcd commit 00a07a3
Show file tree
Hide file tree
Showing 8 changed files with 1,579 additions and 1,423 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Python package

on:
push:
branches: [ main, improve-docs ]
branches: [ main ]
pull_request:
branches: [ main ]

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pytype-checking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pytype Type Check

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install poetry
poetry install
- name: Run pytype
run: poetry run pytype .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
| Badges | |
|:----:|----|
| **Packages and Releases** | [![Latest release](https://img.shields.io/github/release/biomarkersparkinson/tsdf.svg)](https://github.com/biomarkersparkinson/tsdf/releases/latest) [![PyPI](https://img.shields.io/pypi/v/tsdf.svg)](https://pypi.python.org/pypi/tsdf/) [![Static Badge](https://img.shields.io/badge/RSD-tsdf-lib)](https://research-software-directory.org/software/tsdf) |
| **Build Status** | [![](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) ![Python package](https://github.com/biomarkersparkinson/tsdf/workflows/Python%20package/badge.svg) |
| **Build Status** | [![](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) ![Python package](https://github.com/biomarkersparkinson/tsdf/workflows/Python%20package/badge.svg) [![pytype Type Check](https://github.com/biomarkersParkinson/tsdf/actions/workflows/pytype-checking.yml/badge.svg)](https://github.com/biomarkersParkinson/tsdf/actions/workflows/pytype-checking.yml) |
| **DOI** | [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.7867899.svg)](https://doi.org/10.5281/zenodo.7867899) |
| **License** | [![GitHub license](https://img.shields.io/github/license/biomarkersParkinson/tsdf)](https://github.com/biomarkersparkinson/tsdf/blob/main/LICENSE) |
| **Fairness** | [![fair-software.eu](https://img.shields.io/badge/fair--software.eu-%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F%20%20%E2%97%8F-green)](https://fair-software.eu) [![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/8083/badge)](https://www.bestpractices.dev/projects/8083) |
Expand Down
2,949 changes: 1,532 additions & 1,417 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ coverage = "^7.0.0"
matplotlib = "^3.6.3"
mkdocs = "^1.4.2"
mkdocs-jupyter = "^0.22.0"
pytype = "^2024.2.27"

[tool.poetry.scripts]
validate-tsdf = "tsdf.validator:main"
Expand Down
12 changes: 12 additions & 0 deletions pytype.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[pytype]
# Path to source files
inputs = .
# Path to exclude from analysis
exclude =
**/node_modules
**/venv
**/.venv
**/build
**/dist
# Python version (matches the project's runtime environment)
python_version = 3.9
3 changes: 2 additions & 1 deletion src/tsdf/read_tsdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import json
import os
from pathlib import Path
from typing import Dict, List
from tsdf import file_utils
from tsdf.constants import METADATA_NAMING_PATTERN
Expand Down Expand Up @@ -71,7 +72,7 @@ def load_metadatas_from_dir(
return metadatas


def load_metadata_from_path(path: str) -> Dict[str, TSDFMetadata]:
def load_metadata_from_path(path: Path) -> Dict[str, TSDFMetadata]:
"""
Loads a TSDF metadata file, returns a dictionary
Expand Down
6 changes: 3 additions & 3 deletions src/tsdf/write_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"""

import os
from typing import Any, Dict
from typing import Any, Dict, List
import numpy as np
import pandas as pd
from tsdf import numpy_utils
from tsdf import numpy_utils

from tsdf.tsdfmetadata import TSDFMetadata


def write_dataframe_to_binaries(
file_dir: str, df: pd.DataFrame, metadatas: [TSDFMetadata]
file_dir: str, df: pd.DataFrame, metadatas: List[TSDFMetadata]
) -> None:
"""
Save binary file based on the provided pandas DataFrame.
Expand Down

0 comments on commit 00a07a3

Please sign in to comment.