Linting & Formatting
pylint
python3 -m pip install pylint
pylint --generate-toml-config >> pyproject.toml
pyproject.toml
[tool.pylint.main]
ignore-patterns = ["^\\.#", ".*_pb2.pyi?"]
[tool.pylint."messages control"]
disable = [
"bad-inline-option",
"bare-except",
"broad-exception-caught",
"deprecated-pragma",
"file-ignored",
"invalid-name",
"line-too-long",
"locally-disabled",
"missing-class-docstring",
"missing-function-docstring",
"missing-module-docstring",
"raw-checker-failed",
"suppressed-message",
"too-few-public-methods",
"too-many-arguments",
"too-many-return-statements",
"useless-suppression",
"use-symbolic-message-instead",
]
pylint **/*.py
inline 오류 무시
부분적으로만 무시하고 싶은 경우에는 에러가 발생하는 줄에 # pylint: disable=<errorCode>
주석을 추가하면 됩니다.
a._b = 1 # pylint: disable=protected-access
black
python3 -m pip install black
black **/*.py
pyproject.toml
[tool.black]
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.nox
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
include = '\.pyi?$'
line-length = 100
isort
python3 -m pip install isort
isort --profile black **/*.py
pyproject.toml
[tool.isort]
line_length = 100
profile = "black"
skip_gitignore = true
multi_line_output = 3
mypy
python3 -m pip install mypy
pyproject.toml
[tool.mypy]
[[tool.mypy.overrides]]
# module = "<pattern>" # ex) "module.*"
# 옵션
inline 오류 무시
부분적으로만 무시하고 싶은 경우에는 에러가 발생하는 줄에 # type: ignore[<errorCode>, ...]
주석을 추가하면 됩니다.
a: int = 1.0 # type: ignore[assignment]