#author("2024-03-05T16:21:46+09:00","","")
#author("2024-03-05T20:46:55+09:00","","")
#topicpath

////////////////////////////////////////////////////////////////////////////////
* 目次 [#b4ee840e]
#contents();

////////////////////////////////////////////////////////////////////////////////
* 開発環境 [#ge17897e]
- python 開発の為の環境構築を記す。

////////////////////////////////////////////////////////////////////////////////
* emacs 環境 [#emacs]
- python コード用フォーマッタには、flake8, autopep8, pycodestyle isort 等があるが、 emacs で flycheck でのオンタイムチェックを行う関係から、flycheck でサポートされている flake8 と mypy を採用する。

//==============================================================================
** debian 環境での追加パッケージ [#tc06b6be]
- emacs
- elpa-flycheck
- pylint
- flake8
- isort
- elpa-py-isort
- mypy

//==============================================================================
** pylint [#pylint]
- python 用の lint
- python で書かれたコードを入力すると、そのコードの文法上の問題点を指摘する。
- インストールすると、flycheck から使われるようになる。
- 警告の意味が分からない場合は、[[Pylint 3.1.0-dev0 documentation>https://pylint.readthedocs.io/en/latest/index.html]] でキーワード検索することで、問題コード例と修正例を閲覧することが出来る。これを参考に指摘箇所を修正することが出来る。
//------------------------------------------------------------------------------
*** 設定ファイル [#bf6ef9be]
- 下記に配置する:
-- ${HOME}/.config/pylintrc
- 設定ファイルのサンプルは、以下にて出力される
 $ pylint --generate-rcfile > ~/.config/pylintrc


//==============================================================================
** mypy [#s60e75da]
- 静的型チェックを行う。
- 設定ファイルの適用順などは下記を参照:
-- [[The mypy configuration file>https://mypy.readthedocs.io/en/stable/config_file.html#the-mypy-configuration-file]]
//------------------------------------------------------------------------------
*** 設定ファイル [#ca97b726]
- 環境全体で一つの設定ファイルにしたい場合は、下記何れかとなる。
-- ${HOME}/.config/mypy/config
-- ${HOME}/.mypy.ini


//==============================================================================
** flake8 [#e0883e53]
- インストールすると、flycheck から使われるようになる。
//------------------------------------------------------------------------------
*** 設定ファイル [#r2d1eb50]
- 下記に配置する:
-- ${HOME}/.config/flake8

//==============================================================================
** autopep8 [#autopep8]
- python のコーディングルール "PEP8" に準拠していない箇所を指摘したり、修正したりする。
- PEP8 のドキュメント(日本語訳): [[pep8-ja>https://pep8-ja.readthedocs.io/ja/latest/]]

//==============================================================================
** isort [#isort]
- python 標準の import 順に準拠していない箇所を指摘したり、修正したりする。



//==============================================================================
** debian env [#p6456239]
- emacs
- elpa-flycheck
- pylint
- flake8
- isort
- elpa-py-isort
- mypy

//==============================================================================
** configure [#u72597d8]
** configure for emacs [#emacs-config]
- flycheck
 (require 'flycheck)
 
 ;; checking error by compiler                                                                                                                                          
 (flycheck-define-checker c/c++
   "A C/C++ checker using clang++."
   :command ("clang" "-Wall" "-Wextra -std=c++20" source)
   :error-patterns  ((error line-start
                            (file-name) ":" line ":" column ":" " Error: " (message)
                            line-end)
                     (warning line-start
                              (file-name) ":" line ":" column ":" " Warning: " (message)
                              line-end))
   :modes (c-mode c++-mode))
 
 ;; エラーをツールチップ表示する                                                                                 
 ; (with-eval-after-load 'flycheck                                                                               
 ;   (flycheck-pos-tip-mode))                                                                                    
 


- isort
 (when (executable-find "isort") ; システム上に isort があるときだけ                                             
     (require 'py-isort)
     ;; 保存時にバッファ全体を自動整形する                                                                       
     (add-hook 'before-save-hook 'py-isort-before-save)
     )                                                                                                           

//==============================================================================
** links [#ye6be695]
- [[Pythonのリンター・フォーマッターをしっかりと理解する(Flake8, Black, isort, mypy)>https://zenn.dev/tanny/articles/cdb555d6124a2a]]


////////////////////////////////////////////////////////////////////////////////
* links [#ye6be695]
- [[Pythonのリンター・フォーマッターをしっかりと理解する(Flake8, Black, isort, mypy)>https://zenn.dev/tanny/articles/cdb555d6124a2a]]
* VSCode 環境 [#VSCode]

//==============================================================================
** configure for VSCode [#VSCode-config]



////////////////////////////////////////////////////////////////////////////////
* その他のツール [#b5c74002]
//==============================================================================
** autopep8 [#autopep8]
- python のコーディングルール "PEP8" に準拠していない箇所を指摘したり、修正したりする。
- PEP8 のドキュメント(日本語訳): [[pep8-ja>https://pep8-ja.readthedocs.io/ja/latest/]]



////////////////////////////////////////////////////////////////////////////////
* 参考リンク [#k7a77266]
- [[Pythonの主要なLint(pep8, pylint, flake8)の設定方法まとめ>https://qiita.com/zaki-yama/items/d05adce9d23d67144fbf]]



トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS