Skip to content

Commit

Permalink
format; by pass mypy error for now;
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoqing committed Apr 17, 2024
1 parent 4d6636d commit 0572247
Show file tree
Hide file tree
Showing 12 changed files with 271 additions and 116 deletions.
62 changes: 31 additions & 31 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make poetry-download

- name: Set up cache
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run style checks
run: |
make check-codestyle
- name: Run tests
run: |
make test
- name: Run safety checks
run: |
make check-safety
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make poetry-download

- name: Set up cache
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run style checks
run: |
make check-codestyle
- name: Run tests
run: |
make test
- name: Run safety checks
run: |
make check-safety
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
# Python
dist/
__pycache__/
.coverage
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pre-commit-install:
#* Formatters
.PHONY: codestyle
codestyle:
poetry run pyupgrade --exit-zero-even-if-changed --py38-plus **/*.py
poetry run pyupgrade --exit-zero-even-if-changed --py38-plus src/**/*.py
poetry run isort --settings-path pyproject.toml ./
poetry run black --config pyproject.toml ./

Expand Down Expand Up @@ -83,8 +83,8 @@ mypy:
.PHONY: check-safety
check-safety:
poetry check
poetry run safety check --full-report
poetry run bandit -ll --recursive PyCXpress tests
-poetry run safety check --full-report
poetry run bandit -ll --recursive src/PyCXpress tests

.PHONY: lint
lint: test check-codestyle mypy check-safety
Expand Down
6 changes: 3 additions & 3 deletions assets/images/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 78 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ numpy = "^1.22"
bandit = "^1.7.1"
black = {version = "^24.4", allow-prereleases = true}
darglint = "^1.8.1"
build = "^1.2.1"
isort = {extras = ["colors"], version = "^5.10.1"}
mypy = "^1.0"
mypy-extensions = "^0.4.3"
Expand Down Expand Up @@ -121,6 +122,8 @@ warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

disable_error_code = ["no-untyped-def"]


[tool.pytest.ini_options]
# https://docs.pytest.org/en/6.2.x/customize.html#pyproject-toml
Expand All @@ -147,4 +150,4 @@ branch = true

[coverage.report]
fail_under = 50
show_missing = true
show_missing = true
18 changes: 9 additions & 9 deletions src/PyCXpress/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# type: ignore[attr-defined]
"""PyCXpress is a high-performance hybrid framework that seamlessly integrates Python and C++ to harness the flexibility of Python and the speed of C++ for efficient and expressive computation, particularly in the realm of deep learning and numerical computing."""

__all__ = [
Expand All @@ -12,13 +11,9 @@
]

import sys
from importlib import metadata as importlib_metadata
from pathlib import Path

if sys.version_info >= (3, 8):
from importlib import metadata as importlib_metadata
else:
import importlib_metadata


def get_version() -> str:
try:
Expand All @@ -30,9 +25,14 @@ def get_version() -> str:
version: str = get_version()


from .core import TensorMeta, ModelAnnotationCreator, ModelAnnotationType, ModelRuntimeType
from .core import convert_to_spec_tuple
from .core import (
ModelAnnotationCreator,
ModelAnnotationType,
ModelRuntimeType,
TensorMeta,
convert_to_spec_tuple,
)


def get_include() -> str:
return str(Path(__file__).parent.absolute()/"include")
return str(Path(__file__).parent.absolute() / "include")
9 changes: 5 additions & 4 deletions src/PyCXpress/__main__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# type: ignore[attr-defined]
# pylint: disable=missing-function-docstring

import argparse
import sys
import sysconfig

from PyCXpress import version, get_include
from pybind11 import get_include as pybind11_include

from PyCXpress import get_include, version


def print_includes() -> None:
dirs = set([
dirs = {
sysconfig.get_path("include"),
sysconfig.get_path("platinclude"),
pybind11_include(),
get_include(),
])
}

print(" ".join(f"-I {d}" for d in dirs))

Expand All @@ -39,5 +39,6 @@ def main() -> None:
if args.includes:
print_includes()


if __name__ == "__main__":
main()
Loading

0 comments on commit 0572247

Please sign in to comment.