Skip to content

Commit e4473fd

Browse files
authored
Merge pull request #161 from opengisch/docstring
Typehints etc: Not yet the docstrings, but the base to create docstrings
2 parents 557d310 + b245e56 commit e4473fd

File tree

83 files changed

+1589
-1756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1589
-1756
lines changed

.docker/docker-compose.gh.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: '3'
21
services:
32
postgres13:
43
image: postgis/postgis:13-3.4-alpine

.github/workflows/continuous_integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false # keep for now, since 3.22 and 3.28 have different bases than 3.34+
2020
matrix:
21-
qgis_version: [release-3_22, release-3_28, 3.34, latest]
21+
qgis_version: [release-3_22, release-3_28, '3.34', '3.40', latest]
2222
env:
2323
QGIS_TEST_VERSION: ${{ matrix.qgis_version }}
2424
steps:

modelbaker/dataobjects/fields.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""
2-
/***************************************************************************
3-
-------------------
4-
begin : 2017-04-12
5-
git sha : :%H$
6-
copyright : (C) 2017 by OPENGIS.ch
7-
8-
***************************************************************************/
2+
Metadata:
3+
Creation Date: 2017-04-12
4+
Copyright: (C) 2017 by OPENGIS.ch
5+
96
10-
/***************************************************************************
11-
* *
12-
* This program is free software; you can redistribute it and/or modify *
13-
* it under the terms of the GNU General Public License as published by *
14-
* the Free Software Foundation; either version 2 of the License, or *
15-
* (at your option) any later version. *
16-
* *
17-
***************************************************************************/
7+
License:
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the **GNU General Public License** as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
1812
"""
13+
1914
from __future__ import annotations
2015

2116
from typing import TYPE_CHECKING

modelbaker/dataobjects/form.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""
2-
/***************************************************************************
3-
-------------------
4-
begin : 08/08/17
5-
git sha : :%H$
6-
copyright : (C) 2017 by OPENGIS.ch
7-
8-
***************************************************************************/
9-
10-
/***************************************************************************
11-
* *
12-
* This program is free software; you can redistribute it and/or modify *
13-
* it under the terms of the GNU General Public License as published by *
14-
* the Free Software Foundation; either version 2 of the License, or *
15-
* (at your option) any later version. *
16-
* *
17-
***************************************************************************/
2+
Metadata:
3+
Creation Date: 2017-08-08
4+
Copyright: (C) 2017 by OPENGIS.ch
5+
6+
7+
License:
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the **GNU General Public License** as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
1812
"""
13+
1914
from __future__ import annotations
2015

2116
from typing import TYPE_CHECKING, Optional, Union

modelbaker/dataobjects/layers.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""
2-
/***************************************************************************
3-
-------------------
4-
begin : 2016-11-14
5-
git sha : :%H$
6-
copyright : (C) 2016 by OPENGIS.ch
7-
8-
***************************************************************************/
9-
10-
/***************************************************************************
11-
* *
12-
* This program is free software; you can redistribute it and/or modify *
13-
* it under the terms of the GNU General Public License as published by *
14-
* the Free Software Foundation; either version 2 of the License, or *
15-
* (at your option) any later version. *
16-
* *
17-
***************************************************************************/
2+
Metadata:
3+
Creation Date: 2016-11-14
4+
Copyright: (C) 2016 by OPENGIS.ch
5+
6+
7+
License:
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the **GNU General Public License** as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
1812
"""
13+
1914
from __future__ import annotations
2015

2116
import logging
@@ -46,18 +41,18 @@
4641
class Layer:
4742
def __init__(
4843
self,
49-
provider: str = None,
50-
uri: str = None,
51-
name: str = None,
44+
provider: Optional[str] = None,
45+
uri: Optional[str] = None,
46+
name: Optional[str] = None,
5247
srid: Optional[int] = None,
5348
extent: Optional[str] = None,
54-
geometry_column: str = None,
49+
geometry_column: Optional[str] = None,
5550
wkb_type: QgsWkbTypes = QgsWkbTypes.Type.Unknown,
5651
alias: Optional[str] = None,
5752
is_domain: bool = False, # is enumeration or catalogue
5853
is_structure: bool = False,
5954
is_nmrel: bool = False,
60-
display_expression: str = None,
55+
display_expression: Optional[str] = None,
6156
coordinate_precision: Optional[float] = None,
6257
is_basket_table: bool = False,
6358
is_dataset_table: bool = False,
@@ -73,7 +68,7 @@ def __init__(
7368
qmlstylefile: Optional[str] = None,
7469
styles: dict[str, dict[str, str]] = {},
7570
is_enum: bool = False,
76-
base_class: str = None,
71+
base_class: Optional[str] = None,
7772
provider_names_map: dict[
7873
str, str
7974
] = {}, # provider specific column names (e.g. T_Id vs t_id)

modelbaker/dataobjects/legend.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""
2-
/***************************************************************************
3-
-------------------
4-
begin : 2016-12-21
5-
git sha : :%H$
6-
copyright : (C) 2016 by OPENGIS.ch
7-
8-
***************************************************************************/
9-
10-
/***************************************************************************
11-
* *
12-
* This program is free software; you can redistribute it and/or modify *
13-
* it under the terms of the GNU General Public License as published by *
14-
* the Free Software Foundation; either version 2 of the License, or *
15-
* (at your option) any later version. *
16-
* *
17-
***************************************************************************/
2+
Metadata:
3+
Creation Date: 2021-12-16
4+
Copyright: (C) 2016 by OPENGIS.ch
5+
6+
7+
License:
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the **GNU General Public License** as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
1812
"""
13+
1914
from __future__ import annotations
2015

2116
from typing import Any, Optional, Union
@@ -34,9 +29,9 @@
3429
class LegendGroup:
3530
def __init__(
3631
self,
37-
name: str = None,
32+
name: Optional[str] = None,
3833
expanded: bool = True,
39-
ignore_node_names: bool = None,
34+
ignore_node_names: Optional[list[str]] = [],
4035
static_sorting: bool = False,
4136
) -> None:
4237
self.name = name

modelbaker/dataobjects/project.py

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
"""
2-
/***************************************************************************
3-
-------------------
4-
begin : 2016-12-21
5-
git sha : :%H$
6-
copyright : (C) 2016 by OPENGIS.ch
7-
8-
***************************************************************************/
9-
10-
/***************************************************************************
11-
* *
12-
* This program is free software; you can redistribute it and/or modify *
13-
* it under the terms of the GNU General Public License as published by *
14-
* the Free Software Foundation; either version 2 of the License, or *
15-
* (at your option) any later version. *
16-
* *
17-
***************************************************************************/
2+
Metadata:
3+
Creation Date: 2021-12-16
4+
Copyright: (C) 2016 by OPENGIS.ch
5+
6+
7+
License:
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the **GNU General Public License** as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
1812
"""
13+
1914
from __future__ import annotations
2015

2116
from typing import Any, Optional
Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
"""
2-
/***************************************************************************
3-
begin : 13/05/19
4-
git sha : :%H$
5-
copyright : (C) 2019 by Yesid Polania
6-
7-
***************************************************************************/
8-
9-
/***************************************************************************
10-
* *
11-
* This program is free software; you can redistribute it and/or modify *
12-
* it under the terms of the GNU General Public License as published by *
13-
* the Free Software Foundation; either version 2 of the License, or *
14-
* (at your option) any later version. *
15-
* *
16-
***************************************************************************/
2+
Metadata:
3+
Creation Date: 2019-05-13
4+
Copyright: (C) 2019 by Yesid Polania
5+
6+
7+
License:
8+
This program is free software; you can redistribute it and/or modify
9+
it under the terms of the **GNU General Public License** as published by
10+
the Free Software Foundation; either version 2 of the License, or
11+
(at your option) any later version.
1712
"""
13+
1814
from __future__ import annotations
1915

2016
from abc import ABC, abstractmethod
17+
from typing import Optional
2118

2219
from ..iliwrapper.ili2dbconfig import (
2320
Ili2DbCommandConfiguration,
@@ -30,55 +27,51 @@ class DbCommandConfigManager(ABC):
3027
3128
Provides database uri, arguments to ili2db and a way to save and load configurations parameters
3229
based on a object configuration.
33-
34-
:ivar configuration object that will be managed
3530
"""
3631

3732
def __init__(self, configuration: Ili2DbCommandConfiguration) -> None:
38-
"""
39-
:param configuration: Configuration object that will be managed.
40-
:type configuration: :class:`Ili2DbCommandConfiguration`
41-
"""
4233
self.configuration = configuration
4334

4435
@abstractmethod
4536
def get_uri(
46-
self, su: bool = False, qgis: bool = False, fallback_user: str = None
37+
self, su: bool = False, qgis: bool = False, fallback_user: Optional[str] = None
4738
) -> str:
48-
"""Gets database uri (connection string) for db connectors (:class:`DBConnector`).
39+
"""Gets database uri (connection string) for db connectors (DBConnector).
4940
50-
:param bool su: *True* to use super user credentials, *False* otherwise.
51-
:param bool qgis: *True* to use qgis specific credentials (e.g. authcfg), *False* otherwise.
52-
:param str fallback_user: a username as fallback most possibly used when you want to pass your os account name to connect the database
53-
:return: Database uri (connection string).
54-
:rtype str
55-
"""
41+
Args:
42+
su (bool): *True* to use super user credentials, *False* otherwise.
43+
qgis (bool): *True* to use qgis specific credentials (e.g. authcfg), *False* otherwise.
44+
fallback_user (str): a username as fallback most possibly used when you want to pass your os account name to connect the database
45+
46+
Returns:
47+
str: Database uri (connection string)."""
5648

5749
@abstractmethod
5850
def get_db_args(self, hide_password: bool = False, su: bool = False) -> list[str]:
5951
"""Gets a list of ili2db arguments related to database.
6052
61-
:param bool hide_password: *True* to mask the password, *False* otherwise.
62-
:param bool su: *True* to use super user password, *False* otherwise. Default is False.
63-
:return: ili2db arguments list.
64-
:rtype: list
65-
"""
53+
Args:
54+
hide_password (bool): *True* to mask the password, *False* otherwise.
55+
su (bool): *True* to use super user password, *False* otherwise. Default is False.
56+
57+
Returns:
58+
list: ili2db arguments list."""
6659

6760
def get_schema_import_args(self) -> list[str]:
6861
"""Gets a list of ili2db arguments to use in operation schema import.
6962
70-
:return: ili2db arguments list.
71-
:rtype: list
72-
"""
63+
Returns:
64+
list: ili2db arguments list."""
7365
return list()
7466

7567
def get_ili2db_args(self, hide_password: bool = False) -> list[str]:
7668
"""Gets a complete list of ili2db arguments in order to execute the app.
7769
78-
:param bool hide_password: *True* to mask the password, *False* otherwise.
79-
:return: ili2db arguments list.
80-
:rtype: list
81-
"""
70+
Args:
71+
hide_password (bool): *True* to mask the password, *False* otherwise.
72+
73+
Returns:
74+
list: ili2db arguments list."""
8275
db_args = self.get_db_args(hide_password, self.configuration.db_use_super_login)
8376

8477
if type(self.configuration) is SchemaImportConfiguration:
@@ -90,14 +83,8 @@ def get_ili2db_args(self, hide_password: bool = False) -> list[str]:
9083

9184
@abstractmethod
9285
def save_config_in_qsettings(self) -> None:
93-
"""Saves configuration values related to database in QSettings.
94-
95-
:return: None
96-
"""
86+
"""Saves configuration values related to database in QSettings."""
9787

9888
@abstractmethod
9989
def load_config_from_qsettings(self) -> None:
100-
"""Loads configuration values related to database from Qsettings.
101-
102-
:return: None
103-
"""
90+
"""Loads configuration values related to database from Qsettings."""

0 commit comments

Comments
 (0)