Skip to content

Commit 1faa46e

Browse files
committed
added python guidelines for isort configurations
1 parent 3845b93 commit 1faa46e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

content/contributing-code/python-guidelines/contents.lr

+27
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,33 @@ warning for [Whitespace before ':' (E203)][e203].
6363
[skipe203]: https://github.com/search?q=org%3Acreativecommons+%22noqa%3A+E203%22&type=code
6464
[flake8actions]: https://github.com/search?q=org%3Acreativecommons+%22pipenv+run+flake8%22&type=code
6565

66+
## Handling Imports
67+
68+
### Overview
69+
70+
All the imports in the Python code must be done via [isort][isort], a Python utility/library
71+
to sort imports alphabetically, and automatically separated into sections and by type.
72+
It provides a command line utility, Python library and [plugins for various editors](https://github.com/pycqa/isort/wiki/isort-Plugins)
73+
to quickly sort all your imports. It requires Python 3.6+ to run but
74+
supports formatting Python 2 code too.
75+
76+
[isort]: https://github.com/pycqa/isort
77+
78+
79+
### Configuration
80+
81+
There's a good `isort` config which one should follow while contributing
82+
in the Python projects of the creativecommons. These configurations should be a part of
83+
`pyproject.toml` labelled as `[tools.isort]`
84+
85+
- Isort Configuration (`pyproject.toml`): [GitHub Search · org:creativecommons
86+
filename:pyproject.toml][isortconfig]
87+
- GitHub Actions workflow: [GitHub Search · org:creativecommons "pipenv run
88+
isort"][isortactions]
89+
90+
[isortconfig]: https://github.com/search?q=org%3Acreativecommons+filename:pyproject.toml
91+
[isortactions]: https://github.com/search?q=org%3Acreativecommons+%22pipenv+run+isort%22&type=code
92+
6693

6794
## Development Environment
6895

0 commit comments

Comments
 (0)