Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed flake8 errors and removed linter/formatter workflows (#1278)

Jason Villanueva1e049d8bd22f
diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml
deleted file mode 100644
index e13f9c25b..000000000
--- a/.github/workflows/black.yml
+++ /dev/null
@@ -1,73 +0,0 @@
-name: black
-on:
- workflow_dispatch:
-
-jobs:
- format:
- runs-on: windows-latest
- steps:
- - name: Checkout the repository
- uses: actions/checkout@v2
- with:
- fetch-depth: 0
-
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: 3.8
-
- - name: Install black
- run: pip install black
-
- - name: Black
- run: |
- black manim tests example_scenes
- - name: Check for modified files
- shell: bash
- id: git-check
- run: |
- echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
- git ls-files -m>/d/diffmod.txt
- - name: Print Black Version if Failed
- shell: bash
- if: steps.git-check.outputs.modified == 'true'
- run: |
- blackVer=$(black --version)
- blackVersion=$(python -c "print('${blackVer}'.split()[2])")
- date=$(python -c "import time;print(time.localtime().tm_mday)")
- pushBranch="black-${blackVersion}-${date}"
- git config user.name "github-actions"
- git config user.email "[email protected]"
- git checkout -B "$pushBranch"
- git add .
- git commit -m "Running Black On Master"
- - name: Push branch
- if: steps.git-check.outputs.modified == 'true'
- shell: bash
- run: |
- blackVer=$(black --version)
- blackVersion=$(python -c "print('${blackVer}'.split()[2])")
- date=$(python -c "import time;print(time.localtime().tm_mday)")
- pushBranch="black-${blackVersion}-${date}"
- git push -u origin "${pushBranch}" --force
- - name: Make a PR
- if: steps.git-check.outputs.modified == 'true'
- env:
- access_token: ${{ secrets.GITHUB_TOKEN }}
- run: |
- $blackVer = black --version
- $blackVersion = python -c "print('$($blackVer)'.split()[2])"
- $date = python -c "import time;print(time.localtime().tm_mday)"
- $pushBranch="black-$($blackVersion)-$($date)"
- $filechange=(gc "D:/diffmod.txt").split() -join "`n`n"
- $postContents = @{title="Automated PR: Autoformat with black";
- head="manimcommunity:$($pushBranch)";
- base="master";
- body="This an automated pull request. Files Changed are `n `n ```````n$($filechange)`n``````"
- } | ConvertTo-Json -Compress
- echo "$postContents"
- Invoke-WebRequest `
- -Method POST `
- -Headers @{ "Accept" = "application/vnd.github.v3+json"; "Authorization"= "token $($env:access_token)"}`
- -Uri https://api.github.com/repos/manimcommunity/manim/pulls `
- -Body "$($postContents)"
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
deleted file mode 100644
index 85866896b..000000000
--- a/.github/workflows/lint.yml
+++ /dev/null
@@ -1,109 +0,0 @@
-name: Linting
-on:
- pull_request:
- branches:
- - master
-
-jobs:
- check-format:
- runs-on: windows-latest
- steps:
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: 3.8
- - name: Get Fetch Depth
- id: get-depth
- shell: pwsh
- run: |
- $payload = gc "$env:GITHUB_EVENT_PATH" | ConvertFrom-Json
- $commitEndpoint=$($payload.pull_request._links.commits.href)
- echo "$commitEndpoint"
- $commits = Invoke-WebRequest -Uri "$commitEndpoint" | ConvertFrom-Json
- echo "::set-output name=fetch-depth::$($commits.count)"
- - name: Checkout the repository
- uses: actions/checkout@v2
- with:
- fetch-depth: ${{ steps.get-depth.outputs.fetch-depth }}
-
- - name: Install black
- run: pip install black
-
- - name: Get files
- id: files-changes-in-pr
- env:
- depth: ${{ steps.get-depth.outputs.fetch-depth }}
- shell: powershell
- run: |
- bash -c "git diff --name-only HEAD~$($depth) HEAD>/d/changes.txt"
-
- - name: Run Black on top of latest commit
- shell: bash
- run: |
- printf "Checking Files"
- printf $(</d/changes.txt)
- printf "\n"
- content=$(</d/changes.txt)
- while read file
- do
- if [[ ($(python -c "print('${file}'[-3:])") == ".py") && (-f ${file}) ]]
- then
- black --diff $file
- fi
- done </d/changes.txt
- while read file
- do
- if [[ ($(python -c "print('${file}'[-3:])") == ".py") && (-f ${file}) ]]
- then
- black $file
- fi
- done </d/changes.txt
-
- - name: Check File and Report the Files Not formatted
- shell: powershell
- run: |
- if ( $(bash -c "git diff --name-only") -eq "" -or $(bash -c "git diff --name-only") -eq $null ){
- echo 'All files Changed are formatted Correctly'
- } else {
- echo 'These files need formatting.'
- echo "The Filed changed are `n`n $(git ls-files -m)"
- exit 1
- }
- flake-checks:
- runs-on: windows-latest
- steps:
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: 3.8
-
- - name: Checkout the repository
- uses: actions/checkout@v2
-
- - name: Install Dependencies
- run: |
- pip install poetry
- poetry install
-
- - name: Run Flake8
- run: |
- poetry run flake8 manim
-
- isort-checks:
- runs-on: windows-latest
- steps:
- - name: Set up Python
- uses: actions/setup-python@v2
- with:
- python-version: 3.9
-
- - name: Checkout the repository
- uses: actions/checkout@v2
-
- - name: Install Dependencies
- run: |
- pip install isort
-
- - name: Run Isort
- run: |
- isort -c .
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9092801a5..dd590171b 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -21,6 +21,4 @@ repos:
- repo: https://gitlab.com/PyCQA/flake8
rev: 3.9.0
hooks:
- - id: flake8
-
-
+ - id: flake8
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 63cfe7146..41db897a6 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -15,6 +15,8 @@ import sys
from distutils.sysconfig import get_python_lib
from pathlib import Path
+import guzzle_sphinx_theme
+
sys.path.insert(0, os.path.abspath("."))
@@ -85,7 +87,6 @@ exclude_patterns = []
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
-import guzzle_sphinx_theme
html_theme_path = guzzle_sphinx_theme.html_theme_path()
html_theme = "guzzle_sphinx_theme"
@@ -107,6 +108,7 @@ html_static_path = ["_static"]
# This specifies any additional css files that will override the theme's
html_css_files = ["custom.css"]
+
# source links to github
def linkcode_resolve(domain, info):
if domain != "py":
diff --git a/docs/source/contributing/development.rst b/docs/source/contributing/development.rst
index 0c0587571..40ee35e8c 100644
--- a/docs/source/contributing/development.rst
+++ b/docs/source/contributing/development.rst
@@ -51,14 +51,15 @@ For first-time contributors
- See our :doc:`instructions for developers<installation/for_dev>` for
details and continue here afterwards.
-#. Install Pre-Commit (recommended):
+#. Install Pre-Commit:
.. code-block:: shell
poetry run pre-commit install
- This is optional and will ensure during development that each of your
- commit is properly formatted against our formatter, ``black``.
+ This will ensure during development that each of your commits are properly
+ formatted against our linter and formatters, ``black``, ``flake8``, and
+ ``isort``.
You are now ready to work on manim!
diff --git a/example_scenes/advanced_tex_fonts.py b/example_scenes/advanced_tex_fonts.py
index c7d189a59..e0d9f527f 100644
--- a/example_scenes/advanced_tex_fonts.py
+++ b/example_scenes/advanced_tex_fonts.py
@@ -126,7 +126,7 @@ class TexFontTemplateLibrary(Scene):
for font in examples:
try:
write_one_line(font)
- except:
+ except Exception:
print("FAILURE on ", font.description, " - skipping.")
self.play(
diff --git a/tests/conftest.py b/tests/conftest.py
index 7638f4134..f90a4d850 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,12 +1,8 @@
-import logging
import os
import sys
-import numpy as np
import pytest
-from manim import config
-
def pytest_addoption(parser):
parser.addoption(