@@ -9,24 +9,98 @@ focus on the intent of the code and work together with a minimum of friction.
9
9
---
10
10
body:
11
11
12
+
12
13
## Need of Guidelines
13
14
14
15
These Python Guidelines provides context to the developers who are new to the
15
16
codebase and wishes to make any real-world contribution with
16
17
` org:creativecommons ` and be a part of the organization and learn new things
17
18
with the organization.
18
19
19
- ## Code Formatting
20
+
21
+ ## Development Environment
22
+
20
23
21
24
### Overview
22
25
23
- All Python code must be formatted using [ Black] [ black ] , * the uncompromising
24
- Python code formatter* . Each project should contain a ` pyproject.toml `
26
+ Please work to minimize the number of development related technologies. This
27
+ helps minimize the overhead of contributing to multiple projects. Most of our
28
+ projects use either [ Pipenv] [ pipenv ] , _ the Python Development Workflow for
29
+ Humans_ , or [ docker-compose] [ dockercompose ] , _ a tool for defining and running
30
+ multi-container Docker applications_ .
31
+
32
+ [ pipenv ] : https://github.com/pypa/pipenv
33
+ [ dockercompose ] : https://docs.docker.com/compose/
34
+
35
+
36
+ ### Examples
37
+
38
+ - Pipenv configuration: [ GitHub Search · org: creativecommons
39
+ filename: Pipfile ] [ pipenvconf ]
40
+ - Docker Compose configuration: [ GitHub Search · org: creativecommons
41
+ filename: docker-compose .yml] [ dockercomposeconf ]
42
+
43
+ [ pipenvconf ] : https://github.com/search?q=org%3Acreativecommons+filename:Pipfile
44
+ [ dockercomposeconf ] : https://github.com/search?q=org%3Acreativecommons+filename%3Adocker-compose.yml
45
+ [ relatedreadme ] : https://github.com/creativecommons/cccatalog#development-setup-for-airflow-and-api-puller-scripts
46
+
47
+
48
+ ## Development Tools
49
+
50
+ ### Tool Order
51
+
52
+ The recommended order to execute the tools described below is:
53
+ 1 . ` isort ` (will make changes)
54
+ 2 . ` black ` (will make changes)
55
+ 3 . ` flake8 ` (issues warnings)
56
+
57
+ Many of the Python repositories have a ` tools.sh ` helper script to execute them
58
+ in order: [ GitHub Search · org: creativecommons filename: tools .sh] [ tools-sh ] .
59
+
60
+ [ tools-sh ] : https://github.com/search?q=org%3Acreativecommons+filename%3Atools.sh
61
+
62
+
63
+ ### Handling Imports (isort)
64
+
65
+
66
+ #### Overview
67
+
68
+ All the imports in the Python code must be done via [ isort] [ isort ] , a _ Python
69
+ utility/library to sort imports_ alphabetically, and automatically separated
70
+ into sections and by type. It provides a command line utility, Python library
71
+ and [ plugins for various editors] [ isort-plugins ] to quickly sort all your
72
+ imports. It requires Python 3.6+ to run but supports formatting Python 2 code
73
+ too.
74
+
75
+ [ isort ] : https://github.com/pycqa/isort
76
+ [ isort-plugins ] : https://github.com/pycqa/isort/wiki/isort-Plugins
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
83
+ be a part of ` pyproject.toml ` labelled as ` [tools.isort] `
84
+
85
+ - isort configuration (` pyproject.toml ` ): [ GitHub Search · org: creativecommons
86
+ filename: pyproject .toml] [ isortconfig ]
87
+
88
+ [ isortconfig ] : https://github.com/search?q=org%3Acreativecommons+filename:pyproject.toml
89
+
90
+
91
+ ### Code Formatting (black)
92
+
93
+
94
+ #### Overview
95
+
96
+ All Python code must be formatted using [ Black] [ black ] , _ the uncompromising
97
+ Python code formatter_ . Each project should contain a ` pyproject.toml `
25
98
configuration file that limits line length to 79 characters.
26
99
27
100
[ black ] : https://github.com/psf/black
28
101
29
- ### Examples
102
+
103
+ #### Examples
30
104
31
105
- Black configuration (` pyproject.toml ` ): [ GitHub Search · org: creativecommons
32
106
filename: pyproject .toml] [ blackconfig ]
@@ -37,17 +111,19 @@ configuration file that limits line length to 79 characters.
37
111
[ blackactions ] : https://github.com/search?q=org%3Acreativecommons+%22pipenv+run+black%22&type=code
38
112
39
113
40
- ## Style and Quality
114
+ ### Style and Quality (flake8)
41
115
42
- ### Overview
43
116
44
- All Python code must be checked using [ flake8] [ flake8 ] , * a python tool that
45
- glues together pep8, pyflakes, mccabe, and third-party plugins to check
46
- the style and quality of some python code.*
117
+ #### Overview
118
+
119
+ All Python code must be checked using [ flake8] [ flake8 ] , _ a python tool that
120
+ glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check
121
+ the style and quality of some python code._
47
122
48
- [ flake8 ] : https://gitlab .com/pycqa/flake8
123
+ [ flake8 ] : https://github .com/pycqa/flake8
49
124
50
- ### Conflicts with Black
125
+
126
+ #### Conflicts with Black
51
127
52
128
Where flake8 conflicts with Black, the flake8 check should be skipped. For
53
129
example, there are instances where black formats code that generates flake8
@@ -56,7 +132,7 @@ warning for [Whitespace before ':' (E203)][e203].
56
132
[ e203 ] : https://www.flake8rules.com/rules/E203.html
57
133
58
134
59
- ### Examples
135
+ #### Examples
60
136
61
137
- flake8 configuration (` .flake8 ` ): [ GitHub Search · org: creativecommons
62
138
filename:.flake8] [ flake8conf ]
@@ -69,58 +145,6 @@ warning for [Whitespace before ':' (E203)][e203].
69
145
[ skipe203 ] : https://github.com/search?q=org%3Acreativecommons+%22noqa%3A+E203%22&type=code
70
146
[ flake8actions ] : https://github.com/search?q=org%3Acreativecommons+%22pipenv+run+flake8%22&type=code
71
147
72
- ## Handling Imports
73
-
74
- ### Overview
75
-
76
- All the imports in the Python code must be done via [ isort] [ isort ] , a Python
77
- utility/library to sort imports alphabetically, and automatically separated
78
- into sections and by type.
79
- It provides a command line utility, Python library and
80
- [ plugins for various editors] ( https://github.com/pycqa/isort/wiki/isort-Plugins )
81
- to quickly sort all your imports. It requires Python 3.6+ to run but
82
- supports formatting Python 2 code too.
83
-
84
- [ isort ] : https://github.com/pycqa/isort
85
-
86
-
87
- ### Configuration
88
-
89
- There's a good ` isort ` config which one should follow while contributing
90
- in the Python projects of the creativecommons. These configurations should
91
- be a part of ` pyproject.toml ` labelled as ` [tools.isort] `
92
-
93
- - Isort Configuration (` pyproject.toml ` ): [ GitHub Search · org: creativecommons
94
- filename: pyproject .toml] [ isortconfig ]
95
-
96
- [ isortconfig ] : https://github.com/search?q=org%3Acreativecommons+filename:pyproject.toml
97
-
98
-
99
- ## Development Environment
100
-
101
- ### Overview
102
-
103
- Please work to minimize the number of development related technologies. This
104
- helps minimize the overhead of contributing to multiple projects. Most of our
105
- projects use either [ Pipenv] [ pipenv ] , * the Python Development Workflow for
106
- Humans,* or [ docker-compose] [ dockercompose ] , * a tool for defining and running
107
- multi-container Docker applications.*
108
-
109
- [ pipenv ] : https://github.com/pypa/pipenv
110
- [ dockercompose ] : https://docs.docker.com/compose/
111
-
112
-
113
- ### Examples
114
-
115
- - Pipenv configuration: [ GitHub Search · org: creativecommons
116
- filename: Pipfile ] [ pipenvconf ]
117
- - Docker-compose example: [ docker-compose.yml for cccatalog] [ dockercomposeconf ]
118
- and the [ related README.md] [ relatedreadme ]
119
-
120
- [ pipenvconf ] : https://github.com/search?q=org%3Acreativecommons+filename:Pipfile
121
- [ dockercomposeconf ] : https://github.com/creativecommons/cccatalog/blob/master/src/cc_catalog_airflow/docker-compose.yml
122
- [ relatedreadme ] : https://github.com/creativecommons/cccatalog#development-setup-for-airflow-and-api-puller-scripts
123
-
124
148
125
149
## Additional Guidance
126
150
0 commit comments