Skip to content

Commit

Permalink
style: Configure and run isort
Browse files Browse the repository at this point in the history
  • Loading branch information
caksoylar committed Aug 30, 2023
1 parent e9eba99 commit ea8484b
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions keymap_drawer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

import sys
from argparse import ArgumentParser, FileType, Namespace
from pathlib import Path
from importlib.metadata import version
from pathlib import Path

import yaml

from .config import Config, DrawConfig, ParseConfig
from .keymap import KeymapData
from .draw import KeymapDrawer
from .keymap import KeymapData
from .parse import QmkJsonParser, ZmkKeymapParser


Expand Down
3 changes: 2 additions & 1 deletion keymap_drawer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""

from textwrap import dedent
from pydantic import BaseSettings, BaseModel

from pydantic import BaseModel, BaseSettings


class DrawConfig(BaseSettings, env_prefix="KEYMAP_", extra="ignore"):
Expand Down
6 changes: 3 additions & 3 deletions keymap_drawer/draw/combo.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Module containing class and methods to draw combo representations."""
from math import copysign
from io import StringIO
from math import copysign
from typing import Sequence

from keymap_drawer.keymap import LayoutKey, ComboSpec
from keymap_drawer.physical_layout import Point, PhysicalKey, PhysicalLayout
from keymap_drawer.config import DrawConfig
from keymap_drawer.draw.utils import UtilsMixin
from keymap_drawer.keymap import ComboSpec, LayoutKey
from keymap_drawer.physical_layout import PhysicalKey, PhysicalLayout, Point


class ComboDrawerMixin(UtilsMixin):
Expand Down
12 changes: 6 additions & 6 deletions keymap_drawer/draw/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
representation of the keymap using these two.
"""

from io import StringIO
from html import escape
from copy import deepcopy
from typing import Sequence, Mapping, TextIO
from html import escape
from io import StringIO
from typing import Mapping, Sequence, TextIO

from keymap_drawer.keymap import KeymapData, LayoutKey, ComboSpec
from keymap_drawer.physical_layout import Point, PhysicalKey, PhysicalLayout
from keymap_drawer.config import DrawConfig
from keymap_drawer.draw.utils import UtilsMixin
from keymap_drawer.draw.combo import ComboDrawerMixin
from keymap_drawer.draw.utils import UtilsMixin
from keymap_drawer.keymap import ComboSpec, KeymapData, LayoutKey
from keymap_drawer.physical_layout import PhysicalKey, PhysicalLayout, Point


class KeymapDrawer(ComboDrawerMixin, UtilsMixin):
Expand Down
11 changes: 5 additions & 6 deletions keymap_drawer/draw/glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
"""

import re
from pathlib import Path
from functools import lru_cache, partial
from urllib.request import urlopen
from urllib.error import HTTPError
from concurrent.futures import ThreadPoolExecutor
from functools import lru_cache, partial
from pathlib import Path
from typing import Iterable
from urllib.error import HTTPError
from urllib.request import urlopen

from platformdirs import user_cache_dir

from keymap_drawer.keymap import KeymapData, LayoutKey
from keymap_drawer.config import DrawConfig

from keymap_drawer.keymap import KeymapData, LayoutKey

FETCH_WORKERS = 8
FETCH_TIMEOUT = 10
Expand Down
5 changes: 2 additions & 3 deletions keymap_drawer/draw/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from html import escape
from io import StringIO
from typing import Sequence, Literal
from typing import Literal, Sequence

from keymap_drawer.physical_layout import Point
from keymap_drawer.config import DrawConfig
from keymap_drawer.draw.glyph import GlyphMixin

from keymap_drawer.physical_layout import Point

LegendType = Literal["tap", "hold", "shifted"]

Expand Down
10 changes: 5 additions & 5 deletions keymap_drawer/keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
Module with classes that define the keymap representation, with multiple layers
containing key and combo specifications, paired with the physical keyboard layout.
"""
from itertools import chain
from functools import partial
from collections import defaultdict
from typing import Literal, Sequence, Mapping, Iterable
from functools import partial
from itertools import chain
from typing import Iterable, Literal, Mapping, Sequence

from pydantic import BaseModel, Field, validator, root_validator
from pydantic import BaseModel, Field, root_validator, validator

from .physical_layout import layout_factory, PhysicalLayout
from .config import DrawConfig
from .physical_layout import PhysicalLayout, layout_factory


class LayoutKey(BaseModel, allow_population_by_field_name=True):
Expand Down
6 changes: 3 additions & 3 deletions keymap_drawer/parse/dts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"""

import re
from itertools import chain
from io import StringIO
from collections import defaultdict
from io import StringIO
from itertools import chain

import pyparsing as pp
from pcpp.preprocessor import Preprocessor, OutputDirective, Action # type: ignore
from pcpp.preprocessor import Action, OutputDirective, Preprocessor # type: ignore


class DTNode:
Expand Down
5 changes: 2 additions & 3 deletions keymap_drawer/parse/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
Do not use directly, use QmkJsonParser or ZmkKeymapParser instead.
"""

from io import TextIOWrapper
from abc import ABC
from io import TextIOWrapper
from typing import Sequence


from keymap_drawer.keymap import LayoutKey, KeymapData
from keymap_drawer.config import ParseConfig
from keymap_drawer.keymap import KeymapData, LayoutKey


class KeymapParser(ABC): # pylint: disable=too-many-instance-attributes
Expand Down
4 changes: 2 additions & 2 deletions keymap_drawer/parse/qmk.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Module containing class to parse json-format QMK keymaps."""

import re
import json
import re
from typing import Sequence

from keymap_drawer.keymap import LayoutKey, KeymapData
from keymap_drawer.keymap import KeymapData, LayoutKey
from keymap_drawer.parse.parse import KeymapParser


Expand Down
5 changes: 2 additions & 3 deletions keymap_drawer/parse/zmk.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
"""Module containing class to parse devicetree format ZMK keymaps."""

import re
from pathlib import Path
from itertools import chain
from pathlib import Path
from typing import Sequence

import yaml

from keymap_drawer.keymap import LayoutKey, ComboSpec, KeymapData
from keymap_drawer.config import ParseConfig
from keymap_drawer.keymap import ComboSpec, KeymapData, LayoutKey
from keymap_drawer.parse.dts import DeviceTree
from keymap_drawer.parse.parse import KeymapParser


ZMK_LAYOUTS_PATH = Path(__file__).parent.parent.parent / "resources" / "zmk_keyboard_layouts.yaml"


Expand Down
11 changes: 5 additions & 6 deletions keymap_drawer/physical_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
"""

import json
from math import sqrt, sin, cos, pi
from dataclasses import dataclass
from pathlib import Path
from functools import cached_property, lru_cache
from typing import Sequence, Literal
from urllib.request import urlopen
from math import cos, pi, sin, sqrt
from pathlib import Path
from typing import Literal, Sequence
from urllib.error import HTTPError
from urllib.request import urlopen

from pydantic import BaseModel, root_validator
from platformdirs import user_cache_dir
from pydantic import BaseModel, root_validator

from .config import DrawConfig


QMK_LAYOUTS_PATH = Path(__file__).parent.parent / "resources" / "qmk_layouts"
QMK_METADATA_URL = "https://keyboards.qmk.fm/v1/keyboards/{keyboard}/info.json"
CACHE_LAYOUTS_PATH = Path(user_cache_dir("keymap-drawer", False)) / "qmk_layouts"
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ plugins = "pydantic.mypy"

[tool.black]
line-length = 120

[tool.isort]
src_paths = ["keymap_drawer"]
line_length = 120

0 comments on commit ea8484b

Please sign in to comment.