Skip to content

Commit

Permalink
fix pyflakes warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcarneiro authored and Adrian Figueroa committed Jun 3, 2022
1 parent 1f3bb79 commit a8f18ca
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions capnp/contrib/genpyi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"""

from __future__ import annotations
from typing import Any
from typing import Any, Set
import argparse
import sys
import os.path
import importlib
import logging
import keyword
from dataclasses import dataclass, field
import dataclasses

try:
import black
Expand Down Expand Up @@ -57,21 +57,21 @@ def y(*args, **kwargs):
}


@dataclass
@dataclasses.dataclass
class Scope:
name: str
id: int
parent: Scope | None
return_scope: Scope | None
lines: list[str] = field(default_factory=list)
lines: list[str] = dataclasses.field(default_factory=list)


@dataclass
@dataclasses.dataclass
class Type:
schema: Any
name: str
scope: Scope
generic_params: list[str] = field(default_factory=list)
generic_params: list[str] = dataclasses.field(default_factory=list)

@property
def scope_path(self) -> list[Scope]:
Expand Down Expand Up @@ -319,14 +319,14 @@ def gen_struct(schema, writer, name: str = ""):
writer.lookup_type(
field.slot.type.list.elementType.struct.typeId
)
except KeyError as ex:
except KeyError:
gen_nested(raw_field.schema.elementType, writer)
elif field.slot.type.list.elementType.which() == "enum":
try:
writer.lookup_type(
field.slot.type.list.elementType.enum.typeId
)
except KeyError as ex:
except KeyError:
gen_nested(raw_field.schema.elementType, writer)
type_name = writer.type_ref(field.slot.type.list.elementType)
field_py_code = f"{field.name}: List[{type_name}]"
Expand Down Expand Up @@ -357,7 +357,7 @@ def gen_struct(schema, writer, name: str = ""):
elem_type = raw_field.schema
try:
writer.lookup_type(elem_type.node.id)
except KeyError as ex:
except KeyError:
gen_struct(elem_type, writer)
type_name = writer.type_ref(field.slot.type)
field_py_code = f"{field.name}: {type_name}"
Expand Down Expand Up @@ -397,9 +397,9 @@ def gen_struct(schema, writer, name: str = ""):
scoped_name = ".".join([scope.name for scope in scope_path] + [name])
else:
scoped_name = name
writer.writeln(f"@staticmethod")
writer.writeln("@staticmethod")
writer.writeln(f"def from_bytes(data: bytes) -> {scoped_name}: ...")
writer.writeln(f"def to_bytes(self) -> bytes: ...")
writer.writeln("def to_bytes(self) -> bytes: ...")
have_body = True

if schema.node.struct.discriminantCount:
Expand Down

0 comments on commit a8f18ca

Please sign in to comment.