Skip to content

Commit

Permalink
style: remaining all files
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Jan 28, 2024
1 parent 3176bf9 commit e16ee78
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Static typing approach brings here consistent way to define key values to final

examples/types.py
```py
from typing import NewType
from dataclasses import dataclass
from typing import NewType

TaskID = NewType("TaskID", int)

Expand All @@ -45,9 +45,11 @@ class Task:

examples/logtypes.py
```py
from . import types
from typing import Any, Dict

from typelog import LogType
from typing import Dict, Any

from . import types


def TaskID(value: types.TaskID) -> LogType:
Expand All @@ -62,26 +64,23 @@ def Task(value: types.Task) -> LogType:
params.update(value.__dict__)

return wrapper

```

examples/test_examples.py
```py
import logging
import unittest
from typelog import get_logger

import typelog
from . import logtypes
from . import types
from typelog import Loggers, LogConfig
from typelog import LogConfig, Loggers, get_logger
from typelog.types import LibName, LogLevel, RootLogLevel
import logging

logger = get_logger(__name__)
from . import logtypes, types

logger = get_logger(__name__)


class TestExamples(unittest.TestCase):

def setUp(self) -> None:
Loggers(
RootLogLevel(logging.DEBUG),
Expand All @@ -97,12 +96,12 @@ class TestExamples(unittest.TestCase):
logger.warn("Writing something", logtypes.Task(task))

def test_with_fields(self) -> None:

logger2 = logger.with_fields(logtypes.Task(types.Task(smth="aaa", b=1)))
logger3 = logger.with_fields(typelog.String("smth", "asd"), typelog.Int("number", 2))
logger3 = logger.with_fields(
typelog.String("smth", "asd"), typelog.Int("number", 2)
)

logger.info("logger printed")
logger2.info("logger2 printed")
logger3.info("logger3 printed")

```
10 changes: 5 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tasks:
mypy:
desc: Run mypy tests
cmds:
- mypy .
- mypy --exclude .venv .

flake8:
cmds:
Expand All @@ -18,10 +18,10 @@ tasks:
desc: To format with black and remove not needed imported libraries
cmds:
- rm -R typelog-stubs | true
- black typelog
- isort --profile black -sl typelog
- autoflake --remove-all-unused-imports --ignore-init-module-imports -i -r typelog
- isort -m 3 typelog
- black .
- isort --profile black -sl --skip .venv .
- autoflake --remove-all-unused-imports --ignore-init-module-imports -i -r --exclude .venv .
- isort -m 3 --skip .venv .
- task: flake8
- task: mypy

Expand Down
6 changes: 4 additions & 2 deletions examples/logtypes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from . import types
from typing import Any, Dict

from typelog import LogType
from typing import Dict, Any

from . import types


def TaskID(value: types.TaskID) -> LogType:
Expand Down
17 changes: 8 additions & 9 deletions examples/test_examples.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import logging
import unittest
from typelog import get_logger

import typelog
from . import logtypes
from . import types
from typelog import Loggers, LogConfig
from typelog import LogConfig, Loggers, get_logger
from typelog.types import LibName, LogLevel, RootLogLevel
import logging

logger = get_logger(__name__)
from . import logtypes, types

logger = get_logger(__name__)


class TestExamples(unittest.TestCase):

def setUp(self) -> None:
Loggers(
RootLogLevel(logging.DEBUG),
Expand All @@ -28,9 +26,10 @@ def test_another_one(self) -> None:
logger.warn("Writing something", logtypes.Task(task))

def test_with_fields(self) -> None:

logger2 = logger.with_fields(logtypes.Task(types.Task(smth="aaa", b=1)))
logger3 = logger.with_fields(typelog.String("smth", "asd"), typelog.Int("number", 2))
logger3 = logger.with_fields(
typelog.String("smth", "asd"), typelog.Int("number", 2)
)

logger.info("logger printed")
logger2.info("logger2 printed")
Expand Down
2 changes: 1 addition & 1 deletion examples/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import NewType
from dataclasses import dataclass
from typing import NewType

TaskID = NewType("TaskID", int)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# setup.py

from setuptools import setup # type: ignore[import-untyped]
from setuptools import setup # type: ignore[import-untyped]

setup()
setup()
6 changes: 3 additions & 3 deletions stubgen_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"""
from pathlib import Path

pathlist = Path(".").rglob('*.pyi')
pathlist = Path(".").rglob("*.pyi")
for path in pathlist:
path_in_str = str(path)
if ".venv" in path_in_str:
continue

with open(path_in_str, "r") as file:
pyi_file = file.readlines()
with open(path_in_str.replace("-stubs","").replace(".pyi", ".py"), "r") as file:
with open(path_in_str.replace("-stubs", "").replace(".pyi", ".py"), "r") as file:
py_file = file.readlines()

has_new_types = False
Expand All @@ -28,7 +28,7 @@
if "NewType" in py_line:
varname: str = py_line.split(" ")[0]
has_new_types = True

for pyi_i, pyi_line in enumerate(pyi_file):
if f"{varname}: Incomplete\n" == pyi_line:
pyi_file[pyi_i] = py_line
Expand Down

0 comments on commit e16ee78

Please sign in to comment.