mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-12 05:44:06 +00:00
updates on coding style and add permitted style changes
This commit is contained in:
@@ -29,8 +29,8 @@ Please make sure to follow these guidelines:
|
|||||||
it will almost never happen.
|
it will almost never happen.
|
||||||
* Open a separate pull request for each issue you want to address.
|
* 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
|
Don't mix multiple changes. In particular, don't mix style cleanups with
|
||||||
feature pull requests.
|
feature pull requests (exceptions, see 'Style modernisation' below).
|
||||||
* For small fixes and amendmends open a PR directly.
|
* For small fixes and amendments open a PR directly.
|
||||||
If you plan to make larger changes, please open an issue first or comment
|
If you plan to make larger changes, please open an issue first or comment
|
||||||
on the appropriate issue to outline your planned implementation.
|
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
|
## Coding style
|
||||||
|
|
||||||
Nominatim historically hasn't followed a particular coding style but we
|
The coding style for Python is enforced with flake8. It can be tested with:
|
||||||
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:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
make lint
|
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
|
## Testing
|
||||||
|
|
||||||
Before submitting a pull request make sure that the tests pass:
|
Before submitting a pull request make sure that the tests pass:
|
||||||
|
|||||||
Reference in New Issue
Block a user