컴퓨터관련 쪽지
vscode 에서 pylint 사용
프들이
2021. 3. 24. 11:39
나의 경우 다음과 같은 경로를 가지고 있다. 이러한 상황에서 pylint 를 활성화 하면 test_*.py 에서 src 아래의 파일들을 경로를 찾지를 못한다. 이는 PYTHONPATH 에 src 가 들어가 있지 않기 때문이다.
$ tree src test -L 1
src
├── __init__.py
├── details.py
└── oneline.py
test
├── test_details.py
└── test_oneline.py
이를 위해서 .pylintrc 를 생성하고 init-hook='import sys; sys.path.append("./")' 를 해주면 문제가 해결 된다.
.pylintrc 생성
]$ pylint --generate-rcfile > .pylintrc
PYTHONPATH에 root 디렉토리 설정
그 다음 .pytlintc 파일에서
[MASTER]
init-hook='import sys; sys.path.append("./")'
을 적어주면 된다.
반응형