Skip to content

Add python lint #8

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

Merged
merged 1 commit into from
May 6, 2023
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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ jobs:
run: cargo fmt --all -- --check
- name: run clippy
run: cargo clippy --all --all-features -- -Dwarnings

- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: install ruff
run: python -m pip install ruff
- name: run python lint
run: ruff --ignore=E501 ast --show-source
4 changes: 2 additions & 2 deletions ast/asdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def visitConstructor(self, cons, name):

def visitField(self, field, name):
key = str(field.type)
l = self.types.setdefault(key, [])
l = self.types.setdefault(key, []) # noqa
l.append(name)

def visitProduct(self, prod, name):
Expand All @@ -193,7 +193,7 @@ def check(mod):
v.visit(mod)

for t in v.types:
if t not in mod.types and not t in builtin_types:
if t not in mod.types and t not in builtin_types:
v.errors += 1
uses = ", ".join(v.types[t])
print('Undefined type {}, used in {}'.format(t, uses))
Expand Down
2 changes: 1 addition & 1 deletion ast/asdl_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def gen_classdef(self, name, fields, attrs, depth, base="AstNode"):
self.emit(f"struct {structname};", depth)
self.emit("#[pyclass(flags(HAS_DICT, BASETYPE))]", depth)
self.emit(f"impl {structname} {{", depth)
self.emit(f"#[extend_class]", depth + 1)
self.emit("#[extend_class]", depth + 1)
self.emit(
"fn extend_class_with_fields(ctx: &Context, class: &'static Py<PyType>) {",
depth + 1,
Expand Down