updates on coding style and add permitted style changes

This commit is contained in:
Sarah Hoffmann
2026-03-11 10:17:25 +01:00
parent 03b0a35c0a
commit 55ae5f7bdc

View File

@@ -29,8 +29,8 @@ Please make sure to follow these guidelines:
it will almost never happen.
* Open a separate pull request for each issue you want to address.
Don't mix multiple changes. In particular, don't mix style cleanups with
feature pull requests.
* For small fixes and amendmends open a PR directly.
feature pull requests (exceptions, see 'Style modernisation' below).
* For small fixes and amendments open a PR directly.
If you plan to make larger changes, please open an issue first or comment
on the appropriate issue to outline your planned implementation.
@@ -58,27 +58,25 @@ Please see the development section of the Nominatim documentation for
## Coding style
Nominatim historically hasn't followed a particular coding style but we
are in process of consolidating the style. The following rules apply:
* Python code uses the official Python style
* indentation
* SQL use 2 spaces
* all other file types use 4 spaces
* [BSD style](https://en.wikipedia.org/wiki/Indent_style#Allman_style) for braces
* spaces
* spaces before and after equal signs and operators
* no trailing spaces
* no spaces after opening and before closing bracket
* leave out space between a function name and bracket
but add one between control statement(if, while, etc.) and bracket
The coding style is enforced with flake8. It can be tested with:
The coding style for Python is enforced with flake8. It can be tested with:
```
make lint
```
SQL code is currently not linted but should follow the following rules:
* 2 spaces indentation
* UPPER CASE for all SQL keywords
### Style modernisation
There are a few places where we modernize code style as we go. The following
changes can be made when you touch the code anyway:
* update copyright date in the file header to the current year
* switch Python code to use [generics in standard collections](https://docs.python.org/3/whatsnew/3.9.html#type-hinting-generics-in-standard-collections)
## Testing
Before submitting a pull request make sure that the tests pass: