Skip to content

Commit 0d4d0bc

Browse files
committed
[LINT] black & isort & mypy compatable update
1 parent 27a0e17 commit 0d4d0bc

File tree

13 files changed

+84
-55
lines changed

13 files changed

+84
-55
lines changed

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ dev = [
5353
testpaths = ["test"]
5454
python_files = "test_*.py"
5555

56+
[tool.isort]
57+
profile = "black"
58+
5659
[tool.mypy]
5760
strict = true
5861

scripts/format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ set -x
55
base_dir=$(dirname $(dirname $0))
66

77
black --config "${base_dir}/pyproject.toml" --check .
8-
black .
8+
black --config "${base_dir}/pyproject.toml" .

scripts/lint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -x
55
base_dir=$(dirname $(dirname $0))
66

77
isort --sp "${base_dir}/pyproject.toml" --check .
8+
isort --sp "${base_dir}/pyproject.toml" .
89

910
black --config "${base_dir}/pyproject.toml" --check .
1011

src/fastapi_fastkit/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
11
__version__ = "0.0.1"
2+
3+
import os
4+
5+
from rich.console import Console
6+
7+
if "PYTEST_CURRENT_TEST" in os.environ:
8+
console = Console(no_color=True)
9+
else:
10+
console = Console()

src/fastapi_fastkit/backend.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,22 @@
33
#
44
# @author bnbong bbbong9@gmail.com
55
# --------------------------------------------------------------------------
6-
import re
76
import os
8-
import click
9-
7+
import re
8+
from logging import getLogger
109
from typing import Any
1110

12-
from logging import getLogger
11+
import click
1312
from click.core import Context
1413
from rich.panel import Panel
15-
from rich.console import Console
16-
from rich.text import Text
1714
from rich.table import Table
15+
from rich.text import Text
1816

1917
from fastapi_fastkit.core.exceptions import TemplateExceptions
2018

21-
logger = getLogger(__name__)
19+
from . import console
2220

23-
if "PYTEST_CURRENT_TEST" in os.environ:
24-
console = Console(no_color=True)
25-
else:
26-
console = Console()
21+
logger = getLogger(__name__)
2722

2823
REGEX = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b"
2924

src/fastapi_fastkit/cli.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,34 @@
44
# @author bnbong bbbong9@gmail.com
55
# --------------------------------------------------------------------------
66
import os
7-
import click
8-
import subprocess
97
import shutil
10-
11-
from typing import Union
12-
8+
import subprocess
139
from logging import getLogger
10+
from typing import Union
1411

12+
import click
1513
from click.core import BaseCommand, Context
16-
1714
from rich import print
1815
from rich.panel import Panel
19-
from rich.console import Console
2016

21-
from . import __version__
17+
from fastapi_fastkit.core.exceptions import CLIExceptions
18+
from fastapi_fastkit.core.settings import FastkitConfig
19+
from fastapi_fastkit.utils.inspector import delete_project
20+
from fastapi_fastkit.utils.logging import setup_logging
21+
from fastapi_fastkit.utils.transducer import copy_and_convert_template
22+
23+
from . import __version__, console
2224
from .backend import (
23-
validate_email,
25+
create_info_table,
2426
inject_project_metadata,
2527
print_error,
2628
print_success,
2729
print_warning,
28-
create_info_table,
30+
validate_email,
2931
)
30-
from fastapi_fastkit.utils.logging import setup_logging
31-
from fastapi_fastkit.core.settings import FastkitConfig
32-
from fastapi_fastkit.core.exceptions import CLIExceptions
33-
from fastapi_fastkit.utils.transducer import copy_and_convert_template
34-
from fastapi_fastkit.utils.inspector import delete_project
35-
3632

3733
logger = getLogger(__name__)
3834

39-
console = Console()
40-
4135

4236
@click.group()
4337
@click.option("--debug/--no-debug", default=False)
@@ -401,7 +395,7 @@ def runserver(
401395
) -> None:
402396
"""
403397
Run the FastAPI server for the current project.
404-
[TODO] Alternative Point : using FastAPI-fastkit's 'fastapi dev' command
398+
[1.1.0 update TODO] Alternative Point : using FastAPI-fastkit's 'fastapi dev' command
405399
406400
:param ctx: Click context object
407401
:param host: Host address to bind the server to

src/fastapi_fastkit/core/settings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# @author bnbong bbbong9@gmail.com
55
# --------------------------------------------------------------------------
66
import os
7-
87
from pathlib import Path
98

109
from .exceptions import BackendExceptions
@@ -37,7 +36,7 @@ def __get_fastapi_fastkit_root() -> Path:
3736
For installed package: returns the package installation directory
3837
"""
3938
try:
40-
import fastapi_fastkit # pylint: disable=import-outside-toplevel
39+
import fastapi_fastkit
4140

4241
package_root = Path(fastapi_fastkit.__file__).parent.parent
4342
if package_root.name == "site-packages":
@@ -55,7 +54,7 @@ def __get_template_root() -> Path:
5554
For installed package: returns the package template directory
5655
"""
5756
try:
58-
import fastapi_fastkit # pylint: disable=import-outside-toplevel
57+
import fastapi_fastkit
5958

6059
package_root = Path(fastapi_fastkit.__file__).parent
6160
template_dir = package_root / "fastapi_project_template"

src/fastapi_fastkit/utils/logging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# @author bnbong bbbong9@gmail.com
55
# --------------------------------------------------------------------------
66
import logging
7-
87
from typing import Union
98

109
from rich.console import Console

tests/conftest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# --------------------------------------------------------------------------
66
import os
77
import shutil
8+
from typing import Generator
9+
810
import pytest
911

1012
from fastapi_fastkit.core.settings import FastkitConfig
1113

1214

1315
@pytest.fixture(autouse=True, scope="session")
14-
def temp_dir():
16+
def temp_dir() -> Generator[str, None, None]:
1517
"""
1618
Fixture that creates a temporary directory for test cases and yields its path.
1719
After tests are done, the directory is removed.

tests/test_backends/test_configure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# @author bnbong bbbong9@gmail.com
55
# --------------------------------------------------------------------------
66
import os
7-
87
from pathlib import Path
98

109
from click.testing import CliRunner

0 commit comments

Comments
 (0)