Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PKG-INFO 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. Metadata-Version: 1.1
  2. Name: autopep8
  3. Version: 1.3.5
  4. Summary: A tool that automatically formats Python code to conform to the PEP 8 style guide
  5. Home-page: https://github.com/hhatto/autopep8
  6. Author: Hideo Hattori
  7. Author-email: hhatto.jp@gmail.com
  8. License: Expat License
  9. Description: ========
  10. autopep8
  11. ========
  12. .. image:: https://img.shields.io/pypi/v/autopep8.svg
  13. :target: https://pypi.python.org/pypi/autopep8
  14. :alt: PyPI Version
  15. .. image:: https://travis-ci.org/hhatto/autopep8.svg?branch=master
  16. :target: https://travis-ci.org/hhatto/autopep8
  17. :alt: Build status
  18. autopep8 automatically formats Python code to conform to the `PEP 8`_ style
  19. guide. It uses the pycodestyle_ utility to determine what parts of the code
  20. needs to be formatted. autopep8 is capable of fixing most of the formatting
  21. issues_ that can be reported by pycodestyle.
  22. .. _PEP 8: https://www.python.org/dev/peps/pep-0008/
  23. .. _issues: https://pycodestyle.readthedocs.org/en/latest/intro.html#error-codes
  24. .. contents::
  25. Installation
  26. ============
  27. From pip::
  28. $ pip install --upgrade autopep8
  29. Consider using the ``--user`` option_.
  30. .. _option: https://pip.pypa.io/en/latest/user_guide/#user-installs
  31. Requirements
  32. ============
  33. autopep8 requires pycodestyle_.
  34. .. _pycodestyle: https://github.com/PyCQA/pycodestyle
  35. Usage
  36. =====
  37. To modify a file in place (with aggressive level 2)::
  38. $ autopep8 --in-place --aggressive --aggressive <filename>
  39. Before running autopep8.
  40. .. code-block:: python
  41. import math, sys;
  42. def example1():
  43. ####This is a long comment. This should be wrapped to fit within 72 characters.
  44. some_tuple=( 1,2, 3,'a' );
  45. some_variable={'long':'Long code lines should be wrapped within 79 characters.',
  46. 'other':[math.pi, 100,200,300,9876543210,'This is a long string that goes on'],
  47. 'more':{'inner':'This whole logical line should be wrapped.',some_tuple:[1,
  48. 20,300,40000,500000000,60000000000000000]}}
  49. return (some_tuple, some_variable)
  50. def example2(): return {'has_key() is deprecated':True}.has_key({'f':2}.has_key(''));
  51. class Example3( object ):
  52. def __init__ ( self, bar ):
  53. #Comments should have a space after the hash.
  54. if bar : bar+=1; bar=bar* bar ; return bar
  55. else:
  56. some_string = """
  57. Indentation in multiline strings should not be touched.
  58. Only actual code should be reindented.
  59. """
  60. return (sys.path, some_string)
  61. After running autopep8.
  62. .. code-block:: python
  63. import math
  64. import sys
  65. def example1():
  66. # This is a long comment. This should be wrapped to fit within 72
  67. # characters.
  68. some_tuple = (1, 2, 3, 'a')
  69. some_variable = {
  70. 'long': 'Long code lines should be wrapped within 79 characters.',
  71. 'other': [
  72. math.pi,
  73. 100,
  74. 200,
  75. 300,
  76. 9876543210,
  77. 'This is a long string that goes on'],
  78. 'more': {
  79. 'inner': 'This whole logical line should be wrapped.',
  80. some_tuple: [
  81. 1,
  82. 20,
  83. 300,
  84. 40000,
  85. 500000000,
  86. 60000000000000000]}}
  87. return (some_tuple, some_variable)
  88. def example2(): return ('' in {'f': 2}) in {'has_key() is deprecated': True}
  89. class Example3(object):
  90. def __init__(self, bar):
  91. # Comments should have a space after the hash.
  92. if bar:
  93. bar += 1
  94. bar = bar * bar
  95. return bar
  96. else:
  97. some_string = """
  98. Indentation in multiline strings should not be touched.
  99. Only actual code should be reindented.
  100. """
  101. return (sys.path, some_string)
  102. Options::
  103. usage: autopep8 [-h] [--version] [-v] [-d] [-i] [--global-config filename]
  104. [--ignore-local-config] [-r] [-j n] [-p n] [-a]
  105. [--experimental] [--exclude globs] [--list-fixes]
  106. [--ignore errors] [--select errors] [--max-line-length n]
  107. [--line-range line line]
  108. [files [files ...]]
  109. Automatically formats Python code to conform to the PEP 8 style guide.
  110. positional arguments:
  111. files files to format or '-' for standard in
  112. optional arguments:
  113. -h, --help show this help message and exit
  114. --version show program's version number and exit
  115. -v, --verbose print verbose messages; multiple -v result in more
  116. verbose messages
  117. -d, --diff print the diff for the fixed source
  118. -i, --in-place make changes to files in place
  119. --global-config filename
  120. path to a global pep8 config file; if this file does
  121. not exist then this is ignored (default:
  122. ~/.config/pep8)
  123. --ignore-local-config
  124. don't look for and apply local config files; if not
  125. passed, defaults are updated with any config files in
  126. the project's root directory
  127. -r, --recursive run recursively over directories; must be used with
  128. --in-place or --diff
  129. -j n, --jobs n number of parallel jobs; match CPU count if value is
  130. less than 1
  131. -p n, --pep8-passes n
  132. maximum number of additional pep8 passes (default:
  133. infinite)
  134. -a, --aggressive enable non-whitespace changes; multiple -a result in
  135. more aggressive changes
  136. --experimental enable experimental fixes
  137. --exclude globs exclude file/directory names that match these comma-
  138. separated globs
  139. --list-fixes list codes for fixes; used by --ignore and --select
  140. --ignore errors do not fix these errors/warnings (default: E24)
  141. --select errors fix only these errors/warnings (e.g. E4,W)
  142. --max-line-length n set maximum allowed line length (default: 79)
  143. --line-range line line, --range line line
  144. only fix errors found within this inclusive range of
  145. line numbers (e.g. 1 99); line numbers are indexed at
  146. 1
  147. Features
  148. ========
  149. autopep8 fixes the following issues_ reported by pycodestyle_::
  150. E101 - Reindent all lines.
  151. E11 - Fix indentation. (not include E112 and E113)
  152. E121 - Fix indentation to be a multiple of four.
  153. E122 - Add absent indentation for hanging indentation.
  154. E123 - Align closing bracket to match opening bracket.
  155. E124 - Align closing bracket to match visual indentation.
  156. E125 - Indent to distinguish line from next logical line.
  157. E126 - Fix over-indented hanging indentation.
  158. E127 - Fix visual indentation.
  159. E128 - Fix visual indentation.
  160. E20 - Remove extraneous whitespace.
  161. E211 - Remove extraneous whitespace.
  162. E22 - Fix extraneous whitespace around keywords.
  163. E224 - Remove extraneous whitespace around operator.
  164. E226 - Fix missing whitespace around arithmetic operator.
  165. E227 - Fix missing whitespace around bitwise/shift operator.
  166. E228 - Fix missing whitespace around modulo operator.
  167. E231 - Add missing whitespace.
  168. E241 - Fix extraneous whitespace around keywords.
  169. E242 - Remove extraneous whitespace around operator.
  170. E251 - Remove whitespace around parameter '=' sign.
  171. E26 - Fix spacing after comment hash for inline comments.
  172. E265 - Fix spacing after comment hash for block comments.
  173. E27 - Fix extraneous whitespace around keywords.
  174. E301 - Add missing blank line.
  175. E302 - Add missing 2 blank lines.
  176. E303 - Remove extra blank lines.
  177. E304 - Remove blank line following function decorator.
  178. E306 - Expected 1 blank line before a nested definition
  179. E401 - Put imports on separate lines.
  180. E501 - Try to make lines fit within --max-line-length characters.
  181. E502 - Remove extraneous escape of newline.
  182. E701 - Put colon-separated compound statement on separate lines.
  183. E70 - Put semicolon-separated compound statement on separate lines.
  184. E711 - Fix comparison with None.
  185. E712 - Fix comparison with boolean.
  186. E721 - Use "isinstance()" instead of comparing types directly.
  187. E722 - Fix bare except.
  188. W291 - Remove trailing whitespace.
  189. W292 - Add a single newline at the end of the file.
  190. W293 - Remove trailing whitespace on blank line.
  191. W391 - Remove trailing blank lines.
  192. W601 - Use "in" rather than "has_key()".
  193. W602 - Fix deprecated form of raising exception.
  194. W603 - Use "!=" instead of "<>"
  195. W604 - Use "repr()" instead of backticks.
  196. W690 - Fix various deprecated code (via lib2to3).
  197. autopep8 also fixes some issues not found by pycodestyle_.
  198. - Correct deprecated or non-idiomatic Python code (via ``lib2to3``). Use this
  199. for making Python 2.7 code more compatible with Python 3. (This is triggered
  200. if ``W690`` is enabled.)
  201. - Normalize files with mixed line endings.
  202. - Put a blank line between a class docstring and its first method
  203. declaration. (Enabled with ``E301``.)
  204. - Remove blank lines between a function declaration and its docstring. (Enabled
  205. with ``E303``.)
  206. autopep8 avoids fixing some issues found by pycodestyle_.
  207. - ``E112``/``E113`` for non comments are reports of bad indentation that break
  208. syntax rules. These should not be modified at all.
  209. - ``E265``, which refers to spacing after comment hash, is ignored if the
  210. comment looks like code. autopep8 avoids modifying these since they are not
  211. real comments. If you really want to get rid of the pycodestyle_ warning,
  212. consider just removing the commented-out code. (This can be automated via
  213. eradicate_.)
  214. .. _eradicate: https://github.com/myint/eradicate
  215. More advanced usage
  216. ===================
  217. By default autopep8 only makes whitespace changes. Thus, by default, it does
  218. not fix ``E711`` and ``E712``. (Changing ``x == None`` to ``x is None`` may
  219. change the meaning of the program if ``x`` has its ``__eq__`` method
  220. overridden.) Nor does it correct deprecated code ``W6``. To enable these
  221. more aggressive fixes, use the ``--aggressive`` option::
  222. $ autopep8 --aggressive <filename>
  223. Use multiple ``--aggressive`` to increase the aggressiveness level. For
  224. example, ``E712`` requires aggressiveness level 2 (since ``x == True`` could be
  225. changed to either ``x`` or ``x is True``, but autopep8 chooses the former).
  226. ``--aggressive`` will also shorten lines more aggressively. It will also remove
  227. trailing whitespace more aggressively. (Usually, we don't touch trailing
  228. whitespace in docstrings and other multiline strings. And to do even more
  229. aggressive changes to docstrings, use docformatter_.)
  230. .. _docformatter: https://github.com/myint/docformatter
  231. To enable only a subset of the fixes, use the ``--select`` option. For example,
  232. to fix various types of indentation issues::
  233. $ autopep8 --select=E1,W1 <filename>
  234. Similarly, to just fix deprecated code::
  235. $ autopep8 --aggressive --select=W6 <filename>
  236. The above is useful when trying to port a single code base to work with both
  237. Python 2 and Python 3 at the same time.
  238. If the file being fixed is large, you may want to enable verbose progress
  239. messages::
  240. $ autopep8 -v <filename>
  241. Use as a module
  242. ===============
  243. The simplest way of using autopep8 as a module is via the ``fix_code()``
  244. function:
  245. >>> import autopep8
  246. >>> autopep8.fix_code('x= 123\n')
  247. 'x = 123\n'
  248. Or with options:
  249. >>> import autopep8
  250. >>> autopep8.fix_code('x.has_key(y)\n',
  251. ... options={'aggressive': 1})
  252. 'y in x\n'
  253. >>> autopep8.fix_code('print( 123 )\n',
  254. ... options={'ignore': ['E']})
  255. 'print( 123 )\n'
  256. Testing
  257. =======
  258. Test cases are in ``test/test_autopep8.py``. They can be run directly via
  259. ``python test/test_autopep8.py`` or via tox_. The latter is useful for
  260. testing against multiple Python interpreters. (We currently test against
  261. CPython versions 2.7, 3.4, 3.5 and 3.6. We also test against PyPy.)
  262. .. _`tox`: https://pypi.python.org/pypi/tox
  263. Broad spectrum testing is available via ``test/acid.py``. This script runs
  264. autopep8 against Python code and checks for correctness and completeness of the
  265. code fixes. It can check that the bytecode remains identical.
  266. ``test/acid_pypi.py`` makes use of ``acid.py`` to test against the latest
  267. released packages on PyPI.
  268. Troubleshooting
  269. ===============
  270. ``pkg_resources.DistributionNotFound``
  271. --------------------------------------
  272. If you are using an ancient version of ``setuptools``, you might encounter
  273. ``pkg_resources.DistributionNotFound`` when trying to run ``autopep8``. Try
  274. upgrading ``setuptools`` to workaround this ``setuptools`` problem::
  275. $ pip install --upgrade setuptools
  276. Use ``sudo`` if you are installing to the system.
  277. Links
  278. =====
  279. * PyPI_
  280. * GitHub_
  281. * `Travis CI`_
  282. * Coveralls_
  283. .. _PyPI: https://pypi.python.org/pypi/autopep8/
  284. .. _GitHub: https://github.com/hhatto/autopep8
  285. .. _`Travis CI`: https://travis-ci.org/hhatto/autopep8
  286. .. _`Coveralls`: https://coveralls.io/r/hhatto/autopep8
  287. Keywords: automation,pep8,format,pycodestyle
  288. Platform: UNKNOWN
  289. Classifier: Development Status :: 5 - Production/Stable
  290. Classifier: Environment :: Console
  291. Classifier: Intended Audience :: Developers
  292. Classifier: License :: OSI Approved :: MIT License
  293. Classifier: Operating System :: OS Independent
  294. Classifier: Programming Language :: Python
  295. Classifier: Programming Language :: Python :: 2
  296. Classifier: Programming Language :: Python :: 2.7
  297. Classifier: Programming Language :: Python :: 3
  298. Classifier: Programming Language :: Python :: 3.4
  299. Classifier: Programming Language :: Python :: 3.5
  300. Classifier: Programming Language :: Python :: 3.6
  301. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  302. Classifier: Topic :: Software Development :: Quality Assurance