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.

METADATA 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. Metadata-Version: 2.0
  2. Name: isort
  3. Version: 4.3.4
  4. Summary: A Python utility / library to sort Python imports.
  5. Home-page: https://github.com/timothycrosley/isort
  6. Author: Timothy Crosley
  7. Author-email: timothy.crosley@gmail.com
  8. License: MIT
  9. Keywords: Refactor,Python,Python2,Python3,Refactoring,Imports,Sort,Clean
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 6 - Mature
  12. Classifier: Intended Audience :: Developers
  13. Classifier: Natural Language :: English
  14. Classifier: Environment :: Console
  15. Classifier: License :: OSI Approved :: MIT License
  16. Classifier: Programming Language :: Python
  17. Classifier: Programming Language :: Python :: 2
  18. Classifier: Programming Language :: Python :: 2.7
  19. Classifier: Programming Language :: Python :: 3
  20. Classifier: Programming Language :: Python :: 3.4
  21. Classifier: Programming Language :: Python :: 3.5
  22. Classifier: Programming Language :: Python :: 3.6
  23. Classifier: Programming Language :: Python :: Implementation :: CPython
  24. Classifier: Programming Language :: Python :: Implementation :: PyPy
  25. Classifier: Topic :: Software Development :: Libraries
  26. Classifier: Topic :: Utilities
  27. Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*
  28. Requires-Dist: futures; python_version=="2.7"
  29. .. image:: https://raw.github.com/timothycrosley/isort/master/logo.png
  30. :alt: isort
  31. ########
  32. .. image:: https://badge.fury.io/py/isort.svg
  33. :target: https://badge.fury.io/py/isort
  34. :alt: PyPI version
  35. .. image:: https://travis-ci.org/timothycrosley/isort.svg?branch=master
  36. :target: https://travis-ci.org/timothycrosley/isort
  37. :alt: Build Status
  38. .. image:: https://coveralls.io/repos/timothycrosley/isort/badge.svg?branch=release%2F2.6.0&service=github
  39. :target: https://coveralls.io/github/timothycrosley/isort?branch=release%2F2.6.0
  40. :alt: Coverage
  41. .. image:: https://img.shields.io/github/license/mashape/apistatus.svg
  42. :target: https://pypi.python.org/pypi/hug/
  43. :alt: License
  44. .. image:: https://badges.gitter.im/Join%20Chat.svg
  45. :alt: Join the chat at https://gitter.im/timothycrosley/isort
  46. :target: https://gitter.im/timothycrosley/isort?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
  47. isort your python imports for you so you don't have to.
  48. isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections.
  49. It provides a command line utility, Python library and `plugins for various editors <https://github.com/timothycrosley/isort/wiki/isort-Plugins>`_ to quickly sort all your imports.
  50. It currently cleanly supports Python 2.7 - 3.6 without any dependencies.
  51. .. image:: https://raw.github.com/timothycrosley/isort/develop/example.gif
  52. :alt: Example Usage
  53. Before isort:
  54. .. code-block:: python
  55. from my_lib import Object
  56. print("Hey")
  57. import os
  58. from my_lib import Object3
  59. from my_lib import Object2
  60. import sys
  61. from third_party import lib15, lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, lib10, lib11, lib12, lib13, lib14
  62. import sys
  63. from __future__ import absolute_import
  64. from third_party import lib3
  65. print("yo")
  66. After isort:
  67. .. code-block:: python
  68. from __future__ import absolute_import
  69. import os
  70. import sys
  71. from third_party import (lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8,
  72. lib9, lib10, lib11, lib12, lib13, lib14, lib15)
  73. from my_lib import Object, Object2, Object3
  74. print("Hey")
  75. print("yo")
  76. Installing isort
  77. ================
  78. Installing isort is as simple as:
  79. .. code-block:: bash
  80. pip install isort
  81. or if you prefer
  82. .. code-block:: bash
  83. easy_install isort
  84. Using isort
  85. ===========
  86. **From the command line**:
  87. .. code-block:: bash
  88. isort mypythonfile.py mypythonfile2.py
  89. or recursively:
  90. .. code-block:: bash
  91. isort -rc .
  92. *which is equivalent to:*
  93. .. code-block:: bash
  94. isort **/*.py
  95. or to see the proposed changes without applying them:
  96. .. code-block:: bash
  97. isort mypythonfile.py --diff
  98. Finally, to atomically run isort against a project, only applying changes if they don't introduce syntax errors do:
  99. .. code-block:: bash
  100. isort -rc --atomic .
  101. (Note: this is disabled by default as it keeps isort from being able to run against code written using a different version of Python)
  102. **From within Python**:
  103. .. code-block:: bash
  104. from isort import SortImports
  105. SortImports("pythonfile.py")
  106. or:
  107. .. code-block:: bash
  108. from isort import SortImports
  109. new_contents = SortImports(file_contents=old_contents).output
  110. **From within Kate:**
  111. .. code-block:: bash
  112. ctrl+[
  113. or:
  114. .. code-block:: bash
  115. menu > Python > Sort Imports
  116. Installing isort's Kate plugin
  117. ==============================
  118. For KDE 4.13+ / Pate 2.0+:
  119. .. code-block:: bash
  120. wget https://raw.github.com/timothycrosley/isort/master/kate_plugin/isort_plugin.py --output-document ~/.kde/share/apps/kate/pate/isort_plugin.py
  121. wget https://raw.github.com/timothycrosley/isort/master/kate_plugin/isort_plugin_ui.rc --output-document ~/.kde/share/apps/kate/pate/isort_plugin_ui.rc
  122. wget https://raw.github.com/timothycrosley/isort/master/kate_plugin/katepart_isort.desktop --output-document ~/.kde/share/kde4/services/katepart_isort.desktop
  123. For all older versions:
  124. .. code-block:: bash
  125. wget https://raw.github.com/timothycrosley/isort/master/kate_plugin/isort_plugin_old.py --output-document ~/.kde/share/apps/kate/pate/isort_plugin.py
  126. You will then need to restart kate and enable Python Plugins as well as the isort plugin itself.
  127. Installing isort's for your preferred text editor
  128. =================================================
  129. Several plugins have been written that enable to use isort from within a variety of text-editors.
  130. You can find a full list of them `on the isort wiki <https://github.com/timothycrosley/isort/wiki/isort-Plugins>`_.
  131. Additionally, I will enthusiastically accept pull requests that include plugins for other text editors
  132. and add documentation for them as I am notified.
  133. How does isort work?
  134. ====================
  135. isort parses specified files for global level import lines (imports outside of try / except blocks, functions, etc..)
  136. and puts them all at the top of the file grouped together by the type of import:
  137. - Future
  138. - Python Standard Library
  139. - Third Party
  140. - Current Python Project
  141. - Explicitly Local (. before import, as in: ``from . import x``)
  142. - Custom Separate Sections (Defined by forced_separate list in configuration file)
  143. - Custom Sections (Defined by sections list in configuration file)
  144. Inside of each section the imports are sorted alphabetically. isort automatically removes duplicate python imports,
  145. and wraps long from imports to the specified line length (defaults to 80).
  146. When will isort not work?
  147. =========================
  148. If you ever have the situation where you need to have a try / except block in the middle of top-level imports or if
  149. your import order is directly linked to precedence.
  150. For example: a common practice in Django settings files is importing * from various settings files to form
  151. a new settings file. In this case if any of the imports change order you are changing the settings definition itself.
  152. However, you can configure isort to skip over just these files - or even to force certain imports to the top.
  153. Configuring isort
  154. =================
  155. If you find the default isort settings do not work well for your project, isort provides several ways to adjust
  156. the behavior.
  157. To configure isort for a single user create a ``~/.isort.cfg`` file:
  158. .. code-block:: ini
  159. [settings]
  160. line_length=120
  161. force_to_top=file1.py,file2.py
  162. skip=file3.py,file4.py
  163. known_future_library=future,pies
  164. known_standard_library=std,std2
  165. known_third_party=randomthirdparty
  166. known_first_party=mylib1,mylib2
  167. indent=' '
  168. multi_line_output=3
  169. length_sort=1
  170. forced_separate=django.contrib,django.utils
  171. default_section=FIRSTPARTY
  172. no_lines_before=LOCALFOLDER
  173. Additionally, you can specify project level configuration simply by placing a ``.isort.cfg`` file at the root of your
  174. project. isort will look up to 25 directories up, from the file it is ran against, to find a project specific configuration.
  175. Or, if you prefer, you can add an isort section to your project's ``setup.cfg`` or ``tox.ini`` file with any desired settings.
  176. You can then override any of these settings by using command line arguments, or by passing in override values to the
  177. SortImports class.
  178. Finally, as of version 3.0 isort supports editorconfig files using the standard syntax defined here:
  179. http://editorconfig.org/
  180. Meaning you place any standard isort configuration parameters within a .editorconfig file under the ``*.py`` section
  181. and they will be honored.
  182. For a full list of isort settings and their meanings `take a look at the isort wiki <https://github.com/timothycrosley/isort/wiki/isort-Settings>`_.
  183. Multi line output modes
  184. =======================
  185. You will notice above the "multi_line_output" setting. This setting defines how from imports wrap when they extend
  186. past the line_length limit and has 6 possible settings:
  187. **0 - Grid**
  188. .. code-block:: python
  189. from third_party import (lib1, lib2, lib3,
  190. lib4, lib5, ...)
  191. **1 - Vertical**
  192. .. code-block:: python
  193. from third_party import (lib1,
  194. lib2,
  195. lib3
  196. lib4,
  197. lib5,
  198. ...)
  199. **2 - Hanging Indent**
  200. .. code-block:: python
  201. from third_party import \
  202. lib1, lib2, lib3, \
  203. lib4, lib5, lib6
  204. **3 - Vertical Hanging Indent**
  205. .. code-block:: python
  206. from third_party import (
  207. lib1,
  208. lib2,
  209. lib3,
  210. lib4,
  211. )
  212. **4 - Hanging Grid**
  213. .. code-block:: python
  214. from third_party import (
  215. lib1, lib2, lib3, lib4,
  216. lib5, ...)
  217. **5 - Hanging Grid Grouped**
  218. .. code-block:: python
  219. from third_party import (
  220. lib1, lib2, lib3, lib4,
  221. lib5, ...
  222. )
  223. **6 - NOQA**
  224. .. code-block:: python
  225. from third_party import lib1, lib2, lib3, ... # NOQA
  226. Alternatively, you can set ``force_single_line`` to ``True`` (``-sl`` on the command line) and every import will appear on its
  227. own line:
  228. .. code-block:: python
  229. from third_party import lib1
  230. from third_party import lib2
  231. from third_party import lib3
  232. ...
  233. Note: to change the how constant indents appear - simply change the indent property with the following accepted formats:
  234. * Number of spaces you would like. For example: 4 would cause standard 4 space indentation.
  235. * Tab
  236. * A verbatim string with quotes around it.
  237. For example:
  238. .. code-block:: python
  239. " "
  240. is equivalent to 4.
  241. For the import styles that use parentheses, you can control whether or not to
  242. include a trailing comma after the last import with the ``include_trailing_comma``
  243. option (defaults to ``False``).
  244. Intelligently Balanced Multi-line Imports
  245. =========================================
  246. As of isort 3.1.0 support for balanced multi-line imports has been added.
  247. With this enabled isort will dynamically change the import length to the one that produces the most balanced grid,
  248. while staying below the maximum import length defined.
  249. Example:
  250. .. code-block:: python
  251. from __future__ import (absolute_import, division,
  252. print_function, unicode_literals)
  253. Will be produced instead of:
  254. .. code-block:: python
  255. from __future__ import (absolute_import, division, print_function,
  256. unicode_literals)
  257. To enable this set ``balanced_wrapping`` to ``True`` in your config or pass the ``-e`` option into the command line utility.
  258. Custom Sections and Ordering
  259. ============================
  260. You can change the section order with ``sections`` option from the default of:
  261. .. code-block:: ini
  262. FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
  263. to your preference:
  264. .. code-block:: ini
  265. sections=FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,LOCALFOLDER
  266. You also can define your own sections and their order.
  267. Example:
  268. .. code-block:: ini
  269. known_django=django
  270. known_pandas=pandas,numpy
  271. sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,PANDAS,FIRSTPARTY,LOCALFOLDER
  272. would create two new sections with the specified known modules.
  273. The ``no_lines_before`` option will prevent the listed sections from being split from the previous section by an empty line.
  274. Example:
  275. .. code-block:: ini
  276. sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
  277. no_lines_before=LOCALFOLDER
  278. would produce a section with both FIRSTPARTY and LOCALFOLDER modules combined.
  279. Auto-comment import sections
  280. ============================
  281. Some projects prefer to have import sections uniquely titled to aid in identifying the sections quickly
  282. when visually scanning. isort can automate this as well. To do this simply set the ``import_heading_{section_name}``
  283. setting for each section you wish to have auto commented - to the desired comment.
  284. For Example:
  285. .. code-block:: ini
  286. import_heading_stdlib=Standard Library
  287. import_heading_firstparty=My Stuff
  288. Would lead to output looking like the following:
  289. .. code-block:: python
  290. # Standard Library
  291. import os
  292. import sys
  293. import django.settings
  294. # My Stuff
  295. import myproject.test
  296. Ordering by import length
  297. =========================
  298. isort also makes it easy to sort your imports by length, simply by setting the ``length_sort`` option to ``True``.
  299. This will result in the following output style:
  300. .. code-block:: python
  301. from evn.util import (
  302. Pool,
  303. Dict,
  304. Options,
  305. Constant,
  306. DecayDict,
  307. UnexpectedCodePath,
  308. )
  309. Skip processing of imports (outside of configuration)
  310. =====================================================
  311. To make isort ignore a single import simply add a comment at the end of the import line containing the text ``isort:skip``:
  312. .. code-block:: python
  313. import module # isort:skip
  314. or:
  315. .. code-block:: python
  316. from xyz import (abc, # isort:skip
  317. yo,
  318. hey)
  319. To make isort skip an entire file simply add ``isort:skip_file`` to the module's doc string:
  320. .. code-block:: python
  321. """ my_module.py
  322. Best module ever
  323. isort:skip_file
  324. """
  325. import b
  326. import a
  327. Adding an import to multiple files
  328. ==================================
  329. isort makes it easy to add an import statement across multiple files, while being assured it's correctly placed.
  330. From the command line:
  331. .. code-block:: bash
  332. isort -a "from __future__ import print_function" *.py
  333. from within Kate:
  334. .. code-block::
  335. ctrl+]
  336. or:
  337. .. code-block::
  338. menu > Python > Add Import
  339. Removing an import from multiple files
  340. ======================================
  341. isort also makes it easy to remove an import from multiple files, without having to be concerned with how it was originally
  342. formatted.
  343. From the command line:
  344. .. code-block:: bash
  345. isort -r "os.system" *.py
  346. from within Kate:
  347. .. code-block::
  348. ctrl+shift+]
  349. or:
  350. .. code-block::
  351. menu > Python > Remove Import
  352. Using isort to verify code
  353. ==========================
  354. The ``--check-only`` option
  355. ---------------------------
  356. isort can also be used to used to verify that code is correctly formatted by running it with ``-c``.
  357. Any files that contain incorrectly sorted and/or formatted imports will be outputted to ``stderr``.
  358. .. code-block:: bash
  359. isort **/*.py -c -vb
  360. SUCCESS: /home/timothy/Projects/Open_Source/isort/isort_kate_plugin.py Everything Looks Good!
  361. ERROR: /home/timothy/Projects/Open_Source/isort/isort/isort.py Imports are incorrectly sorted.
  362. One great place this can be used is with a pre-commit git hook, such as this one by @acdha:
  363. https://gist.github.com/acdha/8717683
  364. This can help to ensure a certain level of code quality throughout a project.
  365. Git hook
  366. --------
  367. isort provides a hook function that can be integrated into your Git pre-commit script to check
  368. Python code before committing.
  369. To cause the commit to fail if there are isort errors (strict mode), include the following in
  370. ``.git/hooks/pre-commit``:
  371. .. code-block:: python
  372. #!/usr/bin/env python
  373. import sys
  374. from isort.hooks import git_hook
  375. sys.exit(git_hook(strict=True))
  376. If you just want to display warnings, but allow the commit to happen anyway, call ``git_hook`` without
  377. the `strict` parameter.
  378. Setuptools integration
  379. ----------------------
  380. Upon installation, isort enables a ``setuptools`` command that checks Python files
  381. declared by your project.
  382. Running ``python setup.py isort`` on the command line will check the files
  383. listed in your ``py_modules`` and ``packages``. If any warning is found,
  384. the command will exit with an error code:
  385. .. code-block:: bash
  386. $ python setup.py isort
  387. Also, to allow users to be able to use the command without having to install
  388. isort themselves, add isort to the setup_requires of your ``setup()`` like so:
  389. .. code-block:: python
  390. setup(
  391. name="project",
  392. packages=["project"],
  393. setup_requires=[
  394. "isort"
  395. ]
  396. )
  397. Why isort?
  398. ==========
  399. isort simply stands for import sort. It was originally called "sortImports" however I got tired of typing the extra
  400. characters and came to the realization camelCase is not pythonic.
  401. I wrote isort because in an organization I used to work in the manager came in one day and decided all code must
  402. have alphabetically sorted imports. The code base was huge - and he meant for us to do it by hand. However, being a
  403. programmer - I'm too lazy to spend 8 hours mindlessly performing a function, but not too lazy to spend 16
  404. hours automating it. I was given permission to open source sortImports and here we are :)
  405. --------------------------------------------
  406. Thanks and I hope you find isort useful!
  407. ~Timothy Crosley