Skip to content

Commit 14cf35c

Browse files
authored
Enforce black (#204)
* Format everything with black * Added black as dev requirement * To be consistent, use a line-length of 80 * Check formatting with black, via Github action Added from seismic-risc: code4romania/seismic-risc@0a7de6c * Add small documentation about black * Run black on pull request * Fix formatting * Small typos fixes * Fix linting after upstream rebase * Catch all cases for xor mixin model * Combine linting with running tests * Update from a 80 line length limit to 120
1 parent bf1cd88 commit 14cf35c

File tree

25 files changed

+531
-414
lines changed

25 files changed

+531
-414
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ jobs:
1616
run: |
1717
python -m pip install --upgrade pip
1818
pip install -r requirements-dev.txt
19+
- name: Check formatting with black
20+
run: |
21+
black --line-length 120 --target-version py37 --check .
1922
- name: Run tests
2023
env:
2124
DJANGO_SETTINGS_MODULE: project_template.settings.dev

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<!-- Please don't remove this: Grab your social icons from https://github.com/carlsednaoui/gitsocial -->
2222

23-
* MAKING PUBLIC INFORMATION TRULY PUBLIC
23+
* MAKING PUBLIC INFORMATION TRULY PUBLIC
2424
* data from asset declarations, including a net worth estimation
2525

2626
**Important!** This project is currently out of sync with the latest version of [Moonsheep](https://github.com/themoonsheep/moonsheep), a library that it is dependent on. In order for development to continue, we must first fix [this critical issue](https://github.com/code4romania/catpol-declaratii/issues/191).
@@ -45,16 +45,23 @@ Catalog Politic - Declaratii de avere - aims to automate the process of parsing
4545

4646
[Built with](#built-with) | [Repos and projects](#repos-and-projects) | [Deployment](#deployment) | [Contributing](#contributing) | [Feedback](#feedback) | [License](#license) | [About Code4Ro](#about-code4ro)
4747

48-
## Built With
48+
## Built With
4949

50-
[Django](https://www.djangoproject.com)
51-
[Moonsheep](http://moonsheep.org/)
50+
[Django](https://www.djangoproject.com)
51+
[Moonsheep](http://moonsheep.org/)
5252

5353
### Programming languages
5454

55-
Python 3.5+
55+
Python 3.5+
5656
Please follow [the Python style guide](python_style_guide.md).
5757

58+
In order to solve the formatting debates, [black](https://github.com/psf/black) is enforced.
59+
Before submiting a PR, you can run
60+
```bash
61+
black --line-length 80 --target-version py37 .
62+
```
63+
and your code will be automatically formatted.
64+
5865
### Platforms
5966

6067
Political Catalogue - Asset Declaration is a web application.
@@ -69,14 +76,13 @@ Political Catalogue - Asset Declaration is a web application.
6976

7077
### Database technology & provider
7178

72-
This remains currently undecided.
79+
[PostgreSQL](https://www.postgresql.org/)
7380

7481
## Repos and projects
7582

76-
[Moonsheep on GitHub](https://github.com/themoonsheep)
77-
[PyBossa on GitHub](https://github.com/Scifabric/pybossa)
83+
[Moonsheep on GitHub](https://github.com/themoonsheep)
7884

79-
## Deployment
85+
## Deployment
8086

8187
Installation process
8288
* Fork this repo

catpol-dependencies/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN apk update && \
55
gcc python-dev musl-dev \
66
postgresql-dev git \
77
build-base python3-dev openblas-dev \
8-
freetype-dev pkgconfig gfortran \
8+
freetype-dev pkgconfig gfortran gettext \
99
bash
1010

1111
RUN pip3 install --upgrade pip setuptools

locale/en/LC_MESSAGES/django.mo

0 Bytes
Binary file not shown.

locale/en/LC_MESSAGES/django.po

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-02-12 20:37+0000\n"
11+
"POT-Creation-Date: 2020-02-17 19:51+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -145,11 +145,11 @@ msgstr ""
145145
msgid "Tip declaratie"
146146
msgstr ""
147147

148-
#: project_template/models.py:109
148+
#: project_template/models.py:109 project_template/tests/test_xor.py:16
149149
msgid "commune"
150150
msgstr "comuna"
151151

152-
#: project_template/models.py:110
152+
#: project_template/models.py:110 project_template/tests/test_xor.py:17
153153
msgid "city"
154154
msgstr ""
155155

@@ -187,12 +187,16 @@ msgstr "Give me a task!"
187187
msgid "SendTheData"
188188
msgstr "Send the data"
189189

190-
#: project_template/utils.py:99
191-
#, python-brace-format
192-
msgid "Invalid field name {field}"
190+
#: project_template/tests/test_xor.py:18
191+
msgid "village"
193192
msgstr ""
194193

195-
#: project_template/utils.py:106
194+
#: project_template/utils.py:98
196195
msgid "Use only one of the following fields: "
197196
msgstr ""
198197

198+
#: project_template/utils.py:107
199+
#, python-brace-format
200+
msgid "Invalid field name {field}"
201+
msgstr ""
202+

locale/ro/LC_MESSAGES/django.mo

99 Bytes
Binary file not shown.

locale/ro/LC_MESSAGES/django.po

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-02-12 21:19+0000\n"
11+
"POT-Creation-Date: 2020-02-17 19:51+0000\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -150,11 +150,11 @@ msgstr ""
150150
msgid "Tip declaratie"
151151
msgstr ""
152152

153-
#: project_template/models.py:109
153+
#: project_template/models.py:109 project_template/tests/test_xor.py:16
154154
msgid "commune"
155155
msgstr "comuna"
156156

157-
#: project_template/models.py:110
157+
#: project_template/models.py:110 project_template/tests/test_xor.py:17
158158
msgid "city"
159159
msgstr "oras"
160160

@@ -188,16 +188,20 @@ msgstr "Catalog Politic"
188188
msgid "GiveMeATask"
189189
msgstr "Dă-mi un task!"
190190

191-
#: project_template/templates/task.html:50
191+
#: project_template/templates/task.html:48
192192
msgid "SendTheData"
193193
msgstr "Salvează"
194194

195-
#: project_template/utils.py:88
195+
#: project_template/tests/test_xor.py:18
196+
msgid "village"
197+
msgstr "sat"
198+
199+
#: project_template/utils.py:98
196200
msgid "Use only one of the following fields: "
197201
msgstr "Foloseste doar unul din urmatoarele campuri: "
198202

199-
#: project_template/utils.py:97
203+
#: project_template/utils.py:107
200204
#, python-brace-format
201205
msgid "Invalid field name {field}"
202-
msgstr ""
206+
msgstr "Campul {field} este invalid"
203207

project_template/config/csv_counties_singleton.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818
CsvCountiesSingleton.__instance = self
1919
with open(self.__path) as csvfile:
2020
reader = csv.DictReader(csvfile)
21-
headers = ['JUDET', 'NUME']
21+
headers = ["JUDET", "NUME"]
2222
for row in reader:
2323
self.__counties.append(row[headers[0]])
2424

@@ -36,6 +36,3 @@ def get_sorted_counties(self):
3636

3737
def get_cities_in_county(self, county):
3838
return self.__cities[county]
39-
40-
41-

project_template/constants.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
# The complete Romanian names of all the tables inside an income declaration
22
DECLARATION_TABLES = {
3-
'land': "Bunuri Imobile - Terenuri",
4-
'buildings': "Bunuri Imobile - Cladiri",
5-
'automobiles': "Bunuri Mobile - Autovehicule/Autoturisme",
6-
'jewelry': "Bunuri Mobile - Metale pretioase, bijuterii, etc",
7-
'extra_valuable': "Bunuri Mobile - Valoare depaseste 3000euro",
8-
'bank_accounts': "Active Financiare - Conturi si depozite bancare",
9-
'investments': "Active Financiare - Plasamente/Investitii directe",
10-
'other_actives': "Alte active producatoare de venituri",
11-
'debts': "Datorii",
12-
'goods': "Cadouri/Servicii",
13-
'salaries': "Venituri ale declarantului si ale membrilor sai de familie - 1. Venituri din salarii",
14-
'independent_activities': "Venituri ale declarantului si ale membrilor sai de familie - 2. Venituri din activitati independente",
15-
'deferred_use': "Venituri ale declarantului si ale membrilor sai de familie - 3. Venituri din cedarea folosintei bunurilor",
16-
'income_investments': "Venituri ale declarantului si ale membrilor sai de familie - 4. Venituri din investitii",
17-
'pensions': "Venituri ale declarantului si ale membrilor sai de familie - 5. Venituri din pensii",
18-
'agriculture': "Venituri ale declarantului si ale membrilor sai de familie - 6. Venituri din activitati agricole",
19-
'gambling': "Venituri ale declarantului si ale membrilor sai de familie - 7. Venituri din premii si jocuri de noroc",
20-
'other_sources': "Venituri ale declarantului si ale membrilor sai de familie - 8. Venituri din alte surse"
3+
"land": "Bunuri Imobile - Terenuri",
4+
"buildings": "Bunuri Imobile - Cladiri",
5+
"automobiles": "Bunuri Mobile - Autovehicule/Autoturisme",
6+
"jewelry": "Bunuri Mobile - Metale pretioase, bijuterii, etc",
7+
"extra_valuable": "Bunuri Mobile - Valoare depaseste 3000euro",
8+
"bank_accounts": "Active Financiare - Conturi si depozite bancare",
9+
"investments": "Active Financiare - Plasamente/Investitii directe",
10+
"other_actives": "Alte active producatoare de venituri",
11+
"debts": "Datorii",
12+
"goods": "Cadouri/Servicii",
13+
"salaries": "Venituri ale declarantului si ale membrilor sai de familie - 1. Venituri din salarii",
14+
"independent_activities": "Venituri ale declarantului si ale membrilor sai de familie - 2. Venituri din activitati independente",
15+
"deferred_use": "Venituri ale declarantului si ale membrilor sai de familie - 3. Venituri din cedarea folosintei bunurilor",
16+
"income_investments": "Venituri ale declarantului si ale membrilor sai de familie - 4. Venituri din investitii",
17+
"pensions": "Venituri ale declarantului si ale membrilor sai de familie - 5. Venituri din pensii",
18+
"agriculture": "Venituri ale declarantului si ale membrilor sai de familie - 6. Venituri din activitati agricole",
19+
"gambling": "Venituri ale declarantului si ale membrilor sai de familie - 7. Venituri din premii si jocuri de noroc",
20+
"other_sources": "Venituri ale declarantului si ale membrilor sai de familie - 8. Venituri din alte surse",
2121
}
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
__all__=['account_type', 'attainment_type', 'building_type', 'common_utils', 'currency', 'debt_type', 'declaration_type', 'estranged_goods_type', 'financial_institution', 'goods_separation_type', 'holder_relationship', 'holder_type', 'income_provider_type', 'institution', 'investment_type', 'mobile_goods_type', 'position', 'real_estate_type']
1+
__all__ = [
2+
"account_type",
3+
"attainment_type",
4+
"building_type",
5+
"common_utils",
6+
"currency",
7+
"debt_type",
8+
"declaration_type",
9+
"estranged_goods_type",
10+
"financial_institution",
11+
"goods_separation_type",
12+
"holder_relationship",
13+
"holder_type",
14+
"income_provider_type",
15+
"institution",
16+
"investment_type",
17+
"mobile_goods_type",
18+
"position",
19+
"real_estate_type",
20+
]

0 commit comments

Comments
 (0)