# 존재하지 않거나 사용하지 않는 패키지가 import 된 경우 찾기
# autoflake 사용
# pip3 install autoflake
# --remove-all-unused-imports 사용 안하는 import 부분 화면 출력
# --in-place 를 사용하면 화면 출력 대신 파일에 바로 적용
fd .py ./aaa | xargs autoflake --remove-all-unused-imports --in-place
# pylint 사용
# pip3 install pylint
# W0611 (unused-import)
fd .py ./aaa | xargs pylint --disable="all" --enable="W0611"
# 추가로 vscode pylint 설정시
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--disable=all",
"--enable=W0611",
],
#####
# black - 포맷팅 중심으로 포맷팅만 볼때는 pylint 보다 빠르다.
# ruff - rust 로 lint, formatting 등의 기능으로 pylint, black 보다 빠르다.
# uv pip install --system pylint black
# pylint check(lint) -> ruff 로 대체
# pylint --disable="all" --enable="W0611" *.py
# black formatting -> ruff 로 대체
# black *.py
# ruff check and formatting
uv pip install --system ruff
ruff check *.py
ruff format *.py
comments:
댓글 쓰기