METADATA 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. Metadata-Version: 2.1
  2. Name: pylama
  3. Version: 8.4.1
  4. Summary: Code audit tool for python
  5. Home-page: https://github.com/klen/pylama
  6. Author: Kirill Klenov
  7. Author-email: horneds@gmail.com
  8. License: MIT
  9. Project-URL: Documentation, https://klen.github.io/pylama
  10. Project-URL: Source code, https://github.com/klen/pylama
  11. Project-URL: Issue tracker, https://github.com/klen/pylama/issues
  12. Keywords: qa,linter,pydocstyle,pycodestyle,mccabe,pylint
  13. Platform: UNKNOWN
  14. Classifier: Development Status :: 5 - Production/Stable
  15. Classifier: Environment :: Console
  16. Classifier: Intended Audience :: Developers
  17. Classifier: Intended Audience :: System Administrators
  18. Classifier: License :: OSI Approved :: MIT License
  19. Classifier: Programming Language :: Python
  20. Classifier: Programming Language :: Python :: 3
  21. Classifier: Programming Language :: Python :: 3.10
  22. Classifier: Programming Language :: Python :: 3.7
  23. Classifier: Programming Language :: Python :: 3.8
  24. Classifier: Programming Language :: Python :: 3.9
  25. Classifier: Topic :: Software Development :: Quality Assurance
  26. Classifier: Topic :: Software Development :: Testing
  27. Requires-Python: >=3.7
  28. License-File: LICENSE
  29. Requires-Dist: mccabe (>=0.7.0)
  30. Requires-Dist: pycodestyle (>=2.9.1)
  31. Requires-Dist: pydocstyle (>=6.1.1)
  32. Requires-Dist: pyflakes (>=2.5.0)
  33. Provides-Extra: all
  34. Requires-Dist: pylint ; extra == 'all'
  35. Requires-Dist: eradicate ; extra == 'all'
  36. Requires-Dist: radon ; extra == 'all'
  37. Requires-Dist: mypy ; extra == 'all'
  38. Requires-Dist: vulture ; extra == 'all'
  39. Provides-Extra: eradicate
  40. Requires-Dist: eradicate ; extra == 'eradicate'
  41. Provides-Extra: mypy
  42. Requires-Dist: mypy ; extra == 'mypy'
  43. Provides-Extra: pylint
  44. Requires-Dist: pylint ; extra == 'pylint'
  45. Provides-Extra: radon
  46. Requires-Dist: radon ; extra == 'radon'
  47. Provides-Extra: tests
  48. Requires-Dist: pytest (>=7.1.2) ; extra == 'tests'
  49. Requires-Dist: pytest-mypy ; extra == 'tests'
  50. Requires-Dist: eradicate (>=2.0.0) ; extra == 'tests'
  51. Requires-Dist: radon (>=5.1.0) ; extra == 'tests'
  52. Requires-Dist: mypy ; extra == 'tests'
  53. Requires-Dist: pylint (>=2.11.1) ; extra == 'tests'
  54. Requires-Dist: pylama-quotes ; extra == 'tests'
  55. Requires-Dist: toml ; extra == 'tests'
  56. Requires-Dist: vulture ; extra == 'tests'
  57. Requires-Dist: types-setuptools ; extra == 'tests'
  58. Requires-Dist: types-toml ; extra == 'tests'
  59. Provides-Extra: toml
  60. Requires-Dist: toml (>=0.10.2) ; extra == 'toml'
  61. Provides-Extra: vulture
  62. Requires-Dist: vulture ; extra == 'vulture'
  63. |logo| Pylama
  64. #############
  65. .. _badges:
  66. .. image:: https://github.com/klen/pylama/workflows/tests/badge.svg
  67. :target: https://github.com/klen/pylama/actions/workflows/tests.yml
  68. :alt: Tests Status
  69. .. image:: https://github.com/klen/pylama/workflows/docs/badge.svg
  70. :target: https://klen.github.io/pylama
  71. :alt: Documentation Status
  72. .. image:: https://img.shields.io/pypi/v/pylama
  73. :target: https://pypi.org/project/pylama/
  74. :alt: PYPI Version
  75. .. image:: https://img.shields.io/pypi/pyversions/pylama
  76. :target: https://pypi.org/project/pylama/
  77. :alt: Python Versions
  78. .. _description:
  79. Code audit tool for Python. Pylama wraps these tools:
  80. * pycodestyle_ (formerly pep8) © 2012-2013, Florent Xicluna;
  81. * pydocstyle_ (formerly pep257 by Vladimir Keleshev) © 2014, Amir Rachum;
  82. * PyFlakes_ © 2005-2013, Kevin Watters;
  83. * Mccabe_ © Ned Batchelder;
  84. * Pylint_ © 2013, Logilab;
  85. * Radon_ © Michele Lacchia
  86. * eradicate_ © Steven Myint;
  87. * Mypy_ © Jukka Lehtosalo and contributors;
  88. * Vulture_ © Jendrik Seipp and contributors;
  89. .. _documentation:
  90. Docs are available at https://klen.github.io/pylama/. Pull requests with
  91. documentation enhancements and/or fixes are awesome and most welcome.
  92. .. _contents:
  93. .. contents::
  94. .. _requirements:
  95. Requirements:
  96. =============
  97. - Python (3.7, 3.8, 3.9, 3.10)
  98. - If your tests are failing on Win platform you are missing: ``curses`` -
  99. http://www.lfd.uci.edu/~gohlke/pythonlibs/ (The curses library supplies a
  100. terminal-independent screen-painting and keyboard-handling facility for
  101. text-based terminals)
  102. For python versions < 3.7 install pylama 7.7.1
  103. .. _installation:
  104. Installation:
  105. =============
  106. **Pylama** can be installed using pip: ::
  107. $ pip install pylama
  108. TOML configuration can be enabled optionally: ::
  109. $ pip install pylama[toml]
  110. You may optionally install the requirements with the library: ::
  111. $ pip install pylama[mypy]
  112. $ pip install pylama[pylint]
  113. $ pip install pylama[eradicate]
  114. $ pip install pylama[radon]
  115. $ pip install pylama[vulture]
  116. Or install them all: ::
  117. $ pip install pylama[all]
  118. .. _quickstart:
  119. Quickstart
  120. ==========
  121. **Pylama** is easy to use and really fun for checking code quality. Just run
  122. `pylama` and get common output from all pylama plugins (pycodestyle_,
  123. PyFlakes_, etc.)
  124. Recursively check the current directory. ::
  125. $ pylama
  126. Recursively check a path. ::
  127. $ pylama <path_to_directory_or_file>
  128. Ignore errors ::
  129. $ pylama -i W,E501
  130. .. note:: You can choose a group of errors like `D`, `E1`, etc, or special errors like `C0312`
  131. Choose code checkers ::
  132. $ pylama -l "pycodestyle,mccabe"
  133. .. _options:
  134. Set Pylama (checkers) options
  135. =============================
  136. Command line options
  137. --------------------
  138. ::
  139. $ pylama --help
  140. usage: pylama [-h] [--version] [--verbose] [--options FILE] [--linters LINTERS] [--from-stdin] [--concurrent] [--format {pydocstyle,pycodestyle,pylint,parsable,json}] [--abspath]
  141. [--max-line-length MAX_LINE_LENGTH] [--select SELECT] [--ignore IGNORE] [--skip SKIP] [--sort SORT] [--report REPORT] [--hook] [--max-complexity MAX_COMPLEXITY]
  142. [--pydocstyle-convention {pep257,numpy,google}] [--pylint-confidence {HIGH,INFERENCE,INFERENCE_FAILURE,UNDEFINED}]
  143. [paths ...]
  144. Code audit tool for python.
  145. positional arguments:
  146. paths Paths to files or directories for code check.
  147. optional arguments:
  148. -h, --help show this help message and exit
  149. --version show program's version number and exit
  150. --verbose, -v Verbose mode.
  151. --options FILE, -o FILE
  152. Specify configuration file. Looks for pylama.ini, setup.cfg, tox.ini, or pytest.ini in the current directory (default: None)
  153. --linters LINTERS, -l LINTERS
  154. Select linters. (comma-separated). Choices are eradicate,mccabe,mypy,pycodestyle,pydocstyle,pyflakes,pylint,isort.
  155. --from-stdin Interpret the stdin as a python script, whose filename needs to be passed as the path argument.
  156. --concurrent, --async
  157. Enable async mode. Useful for checking a lot of files.
  158. --format {pydocstyle,pycodestyle,pylint,parsable,json}, -f {pydocstyle,pycodestyle,pylint,parsable,json}
  159. Choose output format.
  160. --abspath, -a Use absolute paths in output.
  161. --max-line-length MAX_LINE_LENGTH, -m MAX_LINE_LENGTH
  162. Maximum allowed line length
  163. --select SELECT, -s SELECT
  164. Select errors and warnings. (comma-separated list)
  165. --ignore IGNORE, -i IGNORE
  166. Ignore errors and warnings. (comma-separated)
  167. --skip SKIP Skip files by masks (comma-separated, Ex. */messages.py)
  168. --sort SORT Sort result by error types. Ex. E,W,D
  169. --report REPORT, -r REPORT
  170. Send report to file [REPORT]
  171. --hook Install Git (Mercurial) hook.
  172. --max-complexity MAX_COMPLEXITY
  173. Max complexity threshold
  174. .. note:: additional options may be available depending on installed linters
  175. .. _modeline:
  176. File modelines
  177. --------------
  178. You can set options for **Pylama** inside a source file. Use
  179. a pylama *modeline* for this, anywhere in the file.
  180. Format: ::
  181. # pylama:{name1}={value1}:{name2}={value2}:...
  182. For example, ignore warnings except W301: ::
  183. # pylama:ignore=W:select=W301
  184. Disable code checking for current file: ::
  185. # pylama:skip=1
  186. Those options have a higher priority.
  187. .. _skiplines:
  188. Skip lines (noqa)
  189. -----------------
  190. Just add ``# noqa`` at the end of a line to ignore:
  191. ::
  192. def urgent_fuction():
  193. unused_var = 'No errors here' # noqa
  194. .. _config:
  195. Configuration file
  196. ==================
  197. **Pylama** looks for a configuration file in the current directory.
  198. You can use a “global” configuration, stored in `.pylama.ini` in your home
  199. directory. This will be used as a fallback configuration.
  200. The program searches for the first matching configuration file in the
  201. directories of command line argument. Pylama looks for the configuration in
  202. this order: ::
  203. ./pylama.ini
  204. ./pyproject.toml
  205. ./setup.cfg
  206. ./tox.ini
  207. ./pytest.ini
  208. ~/.pylama.ini
  209. The ``--option`` / ``-o`` argument can be used to specify a configuration file.
  210. INI-style configuration
  211. -----------------------
  212. Pylama searches for sections whose names start with `pylama`.
  213. The `pylama` section configures global options like `linters` and `skip`.
  214. ::
  215. [pylama]
  216. format = pylint
  217. skip = */.tox/*,*/.env/*
  218. linters = pylint,mccabe
  219. ignore = F0401,C0111,E731
  220. Set code-checkers' options
  221. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  222. You can set options for a special code checkers with pylama configurations.
  223. ::
  224. [pylama:pyflakes]
  225. builtins = _
  226. [pylama:pycodestyle]
  227. max_line_length = 100
  228. [pylama:pylint]
  229. max_line_length = 100
  230. disable = R
  231. See code-checkers' documentation for more info. Note that dashes are
  232. replaced by underscores (e.g. Pylint's ``max-line-length`` becomes
  233. ``max_line_length``).
  234. Set options for file (group of files)
  235. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  236. You can set options for special file (group of files)
  237. with sections:
  238. The options have a higher priority than in the `pylama` section.
  239. ::
  240. [pylama:*/pylama/main.py]
  241. ignore = C901,R0914,W0212
  242. select = R
  243. [pylama:*/tests.py]
  244. ignore = C0110
  245. [pylama:*/setup.py]
  246. skip = 1
  247. TOML configuration
  248. -----------------------
  249. Pylama searches for sections whose names start with `tool.pylama`.
  250. The `tool.pylama` section configures global options like `linters` and `skip`.
  251. ::
  252. [tool.pylama]
  253. format = "pylint"
  254. skip = "*/.tox/*,*/.env/*"
  255. linters = "pylint,mccabe"
  256. ignore = "F0401,C0111,E731"
  257. Set code-checkers' options
  258. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  259. You can set options for a special code checkers with pylama configurations.
  260. ::
  261. [tool.pylama.linter.pyflakes]
  262. builtins = "_"
  263. [tool.pylama.linter.pycodestyle]
  264. max_line_length = 100
  265. [tool.pylama.linter.pylint]
  266. max_line_length = 100
  267. disable = "R"
  268. See code-checkers' documentation for more info. Note that dashes are
  269. replaced by underscores (e.g. Pylint's ``max-line-length`` becomes
  270. ``max_line_length``).
  271. Set options for file (group of files)
  272. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  273. You can set options for special file (group of files)
  274. with sections:
  275. The options have a higher priority than in the `tool.pylama` section.
  276. ::
  277. [[tool.pylama.files]]
  278. path = "*/pylama/main.py"
  279. ignore = "C901,R0914,W0212"
  280. select = "R"
  281. [[tool.pylama.files]]
  282. path = "pylama:*/tests.py"
  283. ignore = "C0110"
  284. [[tool.pylama.files]]
  285. path = "pylama:*/setup.py"
  286. skip = 1
  287. Pytest integration
  288. ==================
  289. Pylama has Pytest_ support. The package automatically registers itself as a pytest
  290. plugin during installation. Pylama also supports the `pytest_cache` plugin.
  291. Check files with pylama ::
  292. pytest --pylama ...
  293. The recommended way to set pylama options when using pytest — configuration
  294. files (see below).
  295. Writing a linter
  296. ================
  297. You can write a custom extension for Pylama.
  298. The custom linter should be a python module. Its name should be like 'pylama_<name>'.
  299. In 'setup.py', 'pylama.linter' entry point should be defined. ::
  300. setup(
  301. # ...
  302. entry_points={
  303. 'pylama.linter': ['lintername = pylama_lintername.main:Linter'],
  304. }
  305. # ...
  306. )
  307. 'Linter' should be an instance of 'pylama.lint.Linter' class.
  308. It must implement two methods:
  309. 1. ``allow`` takes a `path` argument and returns true if the linter can check this file for errors.
  310. 2. ``run`` takes a `path` argument and `meta` keyword arguments and returns a list of errors.
  311. Example:
  312. --------
  313. Just a virtual 'WOW' checker.
  314. setup.py: ::
  315. setup(
  316. name='pylama_wow',
  317. install_requires=[ 'setuptools' ],
  318. entry_points={
  319. 'pylama.linter': ['wow = pylama_wow.main:Linter'],
  320. }
  321. # ...
  322. )
  323. pylama_wow.py: ::
  324. from pylama.lint import Linter as BaseLinter
  325. class Linter(BaseLinter):
  326. def allow(self, path):
  327. return 'wow' in path
  328. def run(self, path, **meta):
  329. with open(path) as f:
  330. if 'wow' in f.read():
  331. return [{
  332. lnum: 0,
  333. col: 0,
  334. text: '"wow" has been found.',
  335. type: 'WOW'
  336. }]
  337. Run pylama from python code
  338. ---------------------------
  339. ::
  340. from pylama.main import check_paths, parse_options
  341. # Use and/or modify 0 or more of the options defined as keys in the variable my_redefined_options below.
  342. # To use defaults for any option, remove that key completely.
  343. my_redefined_options = {
  344. 'linters': ['pep257', 'pydocstyle', 'pycodestyle', 'pyflakes' ...],
  345. 'ignore': ['D203', 'D213', 'D406', 'D407', 'D413' ...],
  346. 'select': ['R1705' ...],
  347. 'sort': 'F,E,W,C,D,...',
  348. 'skip': '*__init__.py,*/test/*.py,...',
  349. 'async': True,
  350. 'force': True
  351. ...
  352. }
  353. # relative path of the directory in which pylama should check
  354. my_path = '...'
  355. options = parse_options([my_path], **my_redefined_options)
  356. errors = check_paths(my_path, options, rootdir='.')
  357. .. _bagtracker:
  358. Bug tracker
  359. -----------
  360. If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/pylama/issues
  361. .. _contributing:
  362. Contributing
  363. ------------
  364. Development of `pylama` happens at GitHub: https://github.com/klen/pylama
  365. Contributors
  366. ^^^^^^^^^^^^
  367. See CONTRIBUTORS_.
  368. .. _license:
  369. License
  370. -------
  371. This is free software. You are permitted to use, copy, modify, merge, publish,
  372. distribute, sublicense, and/or sell copies of it, under the terms of the MIT
  373. License. See LICENSE file for the complete license.
  374. This software is provided WITHOUT ANY WARRANTY; without even the implied
  375. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
  376. LICENSE file for the complete disclaimer.
  377. .. _links:
  378. .. _CONTRIBUTORS: https://github.com/klen/pylama/graphs/contributors
  379. .. _Mccabe: http://nedbatchelder.com/blog/200803/python_code_complexity_microtool.html
  380. .. _pydocstyle: https://github.com/PyCQA/pydocstyle/
  381. .. _pycodestyle: https://github.com/PyCQA/pycodestyle
  382. .. _PyFlakes: https://github.com/pyflakes/pyflakes
  383. .. _Pylint: http://pylint.org
  384. .. _Pytest: http://pytest.org
  385. .. _klen: http://klen.github.io/
  386. .. _eradicate: https://github.com/myint/eradicate
  387. .. _Mypy: https://github.com/python/mypy
  388. .. _Vulture: https://github.com/jendrikseipp/vulture
  389. .. |logo| image:: https://raw.github.com/klen/pylama/develop/docs/_static/logo.png
  390. :width: 100
  391. .. _Radon: https://github.com/rubik/radon