mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-07 21:25:31 +00:00
Add python lint
This commit is contained in:
parent
6b60f85cc4
commit
a73bac9ed1
3 changed files with 11 additions and 3 deletions
8
.github/workflows/ci.yaml
vendored
8
.github/workflows/ci.yaml
vendored
|
@ -54,3 +54,11 @@ jobs:
|
||||||
run: cargo fmt --all -- --check
|
run: cargo fmt --all -- --check
|
||||||
- name: run clippy
|
- name: run clippy
|
||||||
run: cargo clippy --all --all-features -- -Dwarnings
|
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
|
||||||
|
|
|
@ -176,7 +176,7 @@ class Check(VisitorBase):
|
||||||
|
|
||||||
def visitField(self, field, name):
|
def visitField(self, field, name):
|
||||||
key = str(field.type)
|
key = str(field.type)
|
||||||
l = self.types.setdefault(key, [])
|
l = self.types.setdefault(key, []) # noqa
|
||||||
l.append(name)
|
l.append(name)
|
||||||
|
|
||||||
def visitProduct(self, prod, name):
|
def visitProduct(self, prod, name):
|
||||||
|
@ -193,7 +193,7 @@ def check(mod):
|
||||||
v.visit(mod)
|
v.visit(mod)
|
||||||
|
|
||||||
for t in v.types:
|
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
|
v.errors += 1
|
||||||
uses = ", ".join(v.types[t])
|
uses = ", ".join(v.types[t])
|
||||||
print('Undefined type {}, used in {}'.format(t, uses))
|
print('Undefined type {}, used in {}'.format(t, uses))
|
||||||
|
|
|
@ -447,7 +447,7 @@ class ClassDefVisitor(EmitVisitor):
|
||||||
self.emit(f"struct {structname};", depth)
|
self.emit(f"struct {structname};", depth)
|
||||||
self.emit("#[pyclass(flags(HAS_DICT, BASETYPE))]", depth)
|
self.emit("#[pyclass(flags(HAS_DICT, BASETYPE))]", depth)
|
||||||
self.emit(f"impl {structname} {{", depth)
|
self.emit(f"impl {structname} {{", depth)
|
||||||
self.emit(f"#[extend_class]", depth + 1)
|
self.emit("#[extend_class]", depth + 1)
|
||||||
self.emit(
|
self.emit(
|
||||||
"fn extend_class_with_fields(ctx: &Context, class: &'static Py<PyType>) {",
|
"fn extend_class_with_fields(ctx: &Context, class: &'static Py<PyType>) {",
|
||||||
depth + 1,
|
depth + 1,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue