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

Lint python code #59

Merged
merged 2 commits into from
Jul 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
21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint
on:
- push
- pull_request
jobs:
pep8:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Setup
run: |
sudo apt update -q
sudo apt install -yy python3 python3-pip
pip install flake8
-
name: Check code style
run: |
cd tools && flake8
5 changes: 5 additions & 0 deletions tools/.flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
# E227 missing whitespace around bitwise or shift operator
# W504 line break after binary operator
ignore = E227,W504
max-line-length = 150
13 changes: 4 additions & 9 deletions tools/lottie_markdown.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import re
import sys
import json
import inspect
import dataclasses
from typing import Any
from pathlib import Path
import xml.etree.ElementTree as etree

import graphviz
from markdown.extensions import Extension
from markdown.inlinepatterns import InlineProcessor
from markdown.blockprocessors import BlockProcessor
from markdown.preprocessors import Preprocessor
from markdown.util import HTML_PLACEHOLDER_RE, AtomicString
from mkdocs.utils import get_relative_url

Expand Down Expand Up @@ -158,7 +154,7 @@ def encode(self, json_object, indent, id=None):
raise TypeError(json_object)

def encode_item(self, json_object, hljs_type, href=None):
span = etree.Element("span", {"class": "hljs-"+hljs_type})
span = etree.Element("span", {"class": "hljs-" + hljs_type})
span.text = self.encoder.encode(json_object)

if href:
Expand Down Expand Up @@ -304,7 +300,7 @@ def run(self, parent, blocks):

prop_dict = type.all_properties()

rows = blocks.pop(0)
blocks.pop(0)

div = etree.SubElement(parent, "div")

Expand Down Expand Up @@ -776,7 +772,7 @@ def add_control(self, label, input):
default_value = input.attrib.get("value", "")

input = input_wrapper = etree.Element("select")
for value in self.schema_data.from_path("constants/"+enum_id).values:
for value in self.schema_data.from_path("constants/" + enum_id).values:
option = etree.SubElement(input, "option", {"value": str(value.value)})
option.text = value.title
if str(value.value) == default_value:
Expand Down Expand Up @@ -811,7 +807,6 @@ def add_control(self, label, input):
);
""".format(
pg=input_wrapper.attrib["id"],
id=id_base,
initial=input.attrib.get("value", "null"),
anim_id=self.anim_id,
)
Expand Down Expand Up @@ -1038,7 +1033,7 @@ def run(self, parent, blocks):

element = etree.SubElement(parent, "div", {"class": "playground playground-columns"})

editor = etree.SubElement(element, "div", {"id": "editor_" + id_base})
etree.SubElement(element, "div", {"id": "editor_" + id_base})

json_viewer = "json_viewer_%s" % id_base
json_viewer_parent = json_viewer + "_parent"
Expand Down
7 changes: 5 additions & 2 deletions tools/schema-merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from schema_tools.schema import SchemaPath, Schema
from schema_tools import type_info


def join_parts(
json_data: dict,
path: pathlib.Path,
Expand All @@ -32,6 +33,7 @@ def join_parts(

return json_data


def add_vals_to_unknown_object(
objects,
unknown_type_dict: dict
Expand All @@ -42,9 +44,10 @@ def add_vals_to_unknown_object(
type = ele.properties['ty'].const
if type is not None:
types.append(type)

unknown_type_dict["properties"]["ty"]["not"]["enum"] = types



root = pathlib.Path(__file__).absolute().parent.parent

parser = argparse.ArgumentParser(description="Joins JSON schema in a single file")
Expand Down
8 changes: 4 additions & 4 deletions tools/schema-validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
# By default, tool expects a link for all schema files.
# This is generally true, but may not always be the case
unneededLinks = [
("shapes","base-gradient"),
("layers","unknown-layer"),
("shapes","unknown-shape")
("shapes", "base-gradient"),
("layers", "unknown-layer"),
("shapes", "unknown-shape")
]


class Validator:
def __init__(self):
self.valid_refs = set()
Expand Down Expand Up @@ -118,4 +119,3 @@ def check_links(self, html_path: pathlib.Path):

if validator.has_error:
sys.exit(1)