From 9e639591cbffe0d69e2da2f88bb224621a4b0987 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Sun, 3 Sep 2023 14:05:37 +0530 Subject: [PATCH] Revamp pre-commit config --- .github/workflows/ci.yml | 3 +- .pre-commit-config.yaml | 105 +++++++++++++-------------------------- README.md | 2 +- pyproject.toml | 47 ++++++++---------- riemapp/core.py | 4 +- tests/test_geometry.py | 2 +- 6 files changed, 61 insertions(+), 102 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3cb5a70..f89968e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,8 +31,7 @@ jobs: - uses: pre-commit/action@v3.0.0 build: - name: - Build and test with Python ${{ matrix.python-version }} on ${{ + name: Build and test with Python ${{ matrix.python-version }} on ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }} strategy: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d27f0eb..b13b20f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,11 +2,8 @@ ci: autoupdate_commit_msg: "chore: update pre-commit hooks" autofix_commit_msg: "style: pre-commit fixes" -default_language_version: - python: python3.10 - repos: - - repo: https://github.com/psf/black + - repo: https://github.com/psf/black-pre-commit-mirror rev: 23.7.0 hooks: - id: black-jupyter @@ -21,91 +18,59 @@ repos: - id: check-yaml - id: debug-statements - id: end-of-file-fixer + exclude: ^docs - id: mixed-line-ending - - id: name-tests-test - args: ["--pytest-test-first"] - id: requirements-txt-fixer - id: trailing-whitespace - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.10.0 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: "v0.0.286" hooks: - - id: python-check-blanket-noqa - - id: python-check-blanket-type-ignore - - id: python-no-eval - - id: python-use-type-annotations - - id: rst-backticks - - id: rst-directive-colons - - id: rst-inline-touching-normal + - id: ruff + args: ["--fix", "--show-fixes"] + + - repo: https://github.com/tox-dev/pyproject-fmt + rev: "1.1.0" + hooks: + - id: pyproject-fmt + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.5.1 + hooks: + - id: mypy + files: src + args: [] + additional_dependencies: + - numpy + - packaging - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.0.2" hooks: - id: prettier types_or: [yaml, markdown, html, css, scss, javascript, json] - args: [--prose-wrap=always] + exclude: assets/js/webapp\.js - repo: https://github.com/asottile/blacken-docs rev: 1.16.0 hooks: - id: blacken-docs args: ["-E"] - additional_dependencies: [black==22.8.0] + additional_dependencies: [black==23.1.0] - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 hooks: - - id: isort - args: ["-a", "from __future__ import annotations"] + - id: python-check-blanket-type-ignore + exclude: ^src/vector/backends/_numba_object.py$ + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal - - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + - repo: https://github.com/nbQA-dev/nbQA + rev: 1.7.0 hooks: - - id: pyupgrade + - id: nbqa-pyupgrade args: ["--py37-plus"] - - - repo: https://github.com/hadialqattan/pycln - rev: v2.2.2 - hooks: - - id: pycln - additional_dependencies: [click<8.1] - args: [--all] - stages: [manual] - - - repo: https://github.com/asottile/yesqa - rev: v1.5.0 - hooks: - - id: yesqa - exclude: docs/conf.py - additional_dependencies: &flake8_dependencies - - flake8-bugbear - - flake8-print - - - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - additional_dependencies: *flake8_dependencies - - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 - hooks: - - id: mypy - files: riemapp - args: [--show-error-codes] - additional_dependencies: - - numpy==1.22.0 - - packaging - - - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.5 - hooks: - - id: shellcheck - - - repo: local - hooks: - - id: disallow-caps - name: Disallow improper capitalization - language: pygrep - entry: PyBind|Numpy|Cmake|CCache|Github|PyTest - exclude: .pre-commit-config.yaml + - id: nbqa-isort + args: ["--float-to-top"] diff --git a/README.md b/README.md index bc17960..7ed0cac 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Users and learners may use riemapp to: - Right now, `riemapp` aliases the geometries provided by `manim` under `riemapp.geometry`. Users can either use these alias classes or directly use the `MObject`s provided by `manim`. -- `riemapp` programatically generates `manim` animations, and the code for this +- `riemapp` programmatically generates `manim` animations, and the code for this is available under `riemapp.core`. All of the information added by a user is passed into a placeholder class which inherits `manim.Scene`. This class' object is then used to render the animation. diff --git a/pyproject.toml b/pyproject.toml index aa460e2..064f57e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,14 @@ [build-system] +build-backend = "hatchling.build" requires = [ "hatch-vcs", - "hatchling" + "hatchling", ] -build-backend = "hatchling.build" - [project] name = "riemapp" +description = "Manim powered complex mappings." +readme = "README.md" authors = [ { name = "Saransh Chopra", email = "saransh0701@gmail.com" }, { name = "Agriya Khetarpal", email = "agriyakhetarpal@gmail.com" }, @@ -15,17 +16,14 @@ authors = [ { name = "Onkar Mahapatra", email = "onkarmahapatra627@gmail.com" }, { name = "Parth Tripathi", email = "parthxtripathi03@gmail.com" }, ] -description = "Manim powered complex mappings." -readme = "README.md" requires-python = ">=3.7" classifiers = [ "Development Status :: 4 - Beta", - "Intended Audience :: Science/Research", "Intended Audience :: Developers", + "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", - "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", @@ -35,42 +33,44 @@ classifiers = [ "Topic :: Scientific/Engineering", "Typing :: Typed", ] -dynamic = ["version"] +dynamic = [ + "version", +] dependencies = [ - "manim >=0.16.0", + "manim>=0.16", ] - [project.optional-dependencies] -test = [ - "pytest >=6", - "pytest-cov >=3", -] dev = [ - "pytest >=6", - "pytest-cov >=3", + "pytest>=6", + "pytest-cov>=3", ] docs = [ - "markdown-callouts>=0.2.0", + "markdown-callouts>=0.2", "mkdocs>=1.3.1", "mkdocs-include-exclude-files>=0.0.1", - "mkdocs-jupyter>=0.21.0", + "mkdocs-jupyter>=0.21", "mkdocs-material>=8.3.9", "mkdocstrings-python>=0.7.1", "mkdocstrings-python-legacy>=0.2.3", "pymdown-extensions>=9.5", ] - +test = [ + "pytest>=6", + "pytest-cov>=3", +] [project.urls] -Homepage = "https://github.com/Saransh-cpp/riemapp" "Bug Tracker" = "https://github.com/Saransh-cpp/riemapp/issues" -Discussions = "https://github.com/Saransh-cpp/riemapp/discussions" Changelog = "https://riemapp.readthedocs.io/en/latest/changelog/" +Discussions = "https://github.com/Saransh-cpp/riemapp/discussions" Documentation = "https://riemapp.readthedocs.io/" +Homepage = "https://github.com/Saransh-cpp/riemapp" [tool.hatch] version.source = "vcs" build.hooks.vcs.version-file = "riemapp/version.py" +[tool.isort] +profile = "black" [tool.pytest.ini_options] minversion = "6.0" @@ -86,7 +86,6 @@ testpaths = [ "tests", ] - [tool.mypy] files = "riemapp" python_version = "3.8" @@ -103,7 +102,3 @@ disallow_untyped_defs = false disallow_untyped_calls = false disallow_subclassing_any = false ignore_missing_imports = true - - -[tool.isort] -profile = "black" diff --git a/riemapp/core.py b/riemapp/core.py index 62a7433..5e6f08e 100644 --- a/riemapp/core.py +++ b/riemapp/core.py @@ -83,7 +83,7 @@ class Animate(Scene): """ A placeholder class for manim Scene. - This class is used to construct and generate manim animations programatically. + This class is used to construct and generate manim animations programmatically. Args: f: @@ -118,7 +118,7 @@ def __repr__(self) -> str: def construct(self) -> None: """ - The default manim constructer + The default manim constructor """ self.add_numberplane and self.add(NumberPlane()) self.play(Create(self.f, run_time=self.run_time)) diff --git a/tests/test_geometry.py b/tests/test_geometry.py index 0410aa5..72d5681 100644 --- a/tests/test_geometry.py +++ b/tests/test_geometry.py @@ -66,7 +66,7 @@ def test_polygon(): polygon = rp.geometry.Polygon([2, 4, 8], [1, 0, 0], [4, 4, 8]) assert ( polygon.__repr__() - == f"Polygon(vertices={[v for v in polygon.vertices]}) (alias for manim.Polygon)" + == f"Polygon(vertices={[v for v in polygon.vertices]}) (alias for manim.Polygon)" # noqa: E501 ) assert isinstance(polygon, (rp.geometry.Polygon, manim.Polygon)) assert polygon.vertices == ([2, 4, 8], [1, 0, 0], [4, 4, 8])