Skip to content

Commit

Permalink
Add isort (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
PrVrSs authored Jun 10, 2023
1 parent 9db359c commit df524df
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 296 deletions.
381 changes: 89 additions & 292 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ mypy = "^1.3"
pylint = "^2.17.4"
pytest = "^7.3.1"
pytest-cov = "^4.1.0"
isort = "^5.12.0"

[build-system]
requires = ["poetry>=0.12"]
Expand Down
1 change: 1 addition & 0 deletions pywebidl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .parser import Parser as WebIDLParser
from .visitor import Visitor as WebIDLVisitor


__all__ = (
'WebIDLParser',
'WebIDLVisitor',
Expand Down
2 changes: 1 addition & 1 deletion pywebidl2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import click

from .idl import validate, parse
from .idl import parse, validate


_actions = {
Expand Down
2 changes: 1 addition & 1 deletion pywebidl2/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from typing import ClassVar, Dict, List, NamedTuple, cast

from antlr4 import BailErrorStrategy, CommonTokenStream, InputStream
from antlr4.error.Errors import ParseCancellationException
from antlr4.error.ErrorListener import ErrorListener
from antlr4.error.Errors import ParseCancellationException
from antlr4.error.ErrorStrategy import DefaultErrorStrategy, ErrorStrategy
from antlr4.Parser import ParserRuleContext

Expand Down
4 changes: 2 additions & 2 deletions pywebidl2/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections import deque
from contextlib import suppress
from typing import Any, Optional, TypeVar, Union
from typing import Any, TypeVar


_U = TypeVar('_U')
Expand All @@ -17,7 +17,7 @@ def setup_type(idl_type: Any, type_: str) -> None:
todo.extend(idl_type.idl_type)


def escaped_name(string: Optional[_U]) -> Union[Optional[_U], str]:
def escaped_name(string: _U | str) -> _U | str:
if isinstance(string, str):
return string.lstrip('_')

Expand Down
17 changes: 17 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ pretty = True
;Prefixes each error with the relevant context.
show_error_context = True

;Type checks the body of every function, regardless of whether it has type annotations.
check_untyped_defs = True

[mypy-*.generated.*]
;Ignores all non-fatal errors.
ignore_errors = True

[isort]
; The number of blank lines to place after imports.
lines_after_imports = 2
; Includes a trailing comma on multi line imports that include parentheses.
include_trailing_comma = True
; Use parentheses for line continuation on length limit instead of backslashes.
use_parentheses = True
; Inserts a blank line before a comment following an import.
ensure_newline_before_comments = True
; The max length of an import line (used for wrapping long imports).
line_length = 120
; Multi line output opt
multi_line_output=3

0 comments on commit df524df

Please sign in to comment.