Skip to content

Commit

Permalink
Type annotations destroy some functions (#302)
Browse files Browse the repository at this point in the history
* fix
  • Loading branch information
why-not-try-calmer authored Nov 21, 2023
1 parent affd27e commit b74583a
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 19 deletions.
8 changes: 4 additions & 4 deletions comptages/chart/chart_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, iface, layers, parent=None):
self.count = None
self.sensor = None

def set_attributes(self, count: models.Count):
def set_attributes(self, count):
self.count = count

self.setWindowTitle(
Expand Down Expand Up @@ -63,7 +63,7 @@ def set_attributes(self, count: models.Count):

self._create_tabs(count)

def _create_tabs(self, count: models.Count):
def _create_tabs(self, count):
try:
self.tabWidget.currentChanged.disconnect(self.current_tab_changed)
except Exception:
Expand All @@ -81,7 +81,7 @@ def _create_tabs(self, count: models.Count):
self.tabWidget.addTab(tab, section.id)
self._populate_tab(tab, section, count)

def _populate_tab(self, tab, section: models.Section, count: models.Count):
def _populate_tab(self, tab, section, count):
# Check if there is data to be validated
approval_process = False
if models.CountDetail.objects.filter(
Expand Down Expand Up @@ -112,7 +112,7 @@ def _populate_tab(self, tab, section: models.Section, count: models.Count):
tab.buttonValidate.hide()
tab.buttonRefuse.hide()

sensor_type: models.SensorType = count.id_sensor_type
sensor_type = count.id_sensor_type
lanes = models.Lane.objects.filter(id_section=section)
directions = (
lanes.values("direction").distinct().values_list("direction", flat=True)
Expand Down
8 changes: 3 additions & 5 deletions comptages/core/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def simple_print_callback(progress):
print(f"Importing... {progress}%")


def import_file(
file_path: str, count: models.Count, callback_progress=simple_print_callback
):
def import_file(file_path: str, count, callback_progress=simple_print_callback):
file_format = get_file_format(file_path)
file_header = _parse_file_header(file_path)

Expand Down Expand Up @@ -46,7 +44,7 @@ def import_file(

def _parse_and_write(
file_path: str,
count: models.Count,
count,
line_parser: Callable,
callback_progress,
from_aggregate: bool = False,
Expand Down Expand Up @@ -360,7 +358,7 @@ def _parse_data_header(file_path: str) -> List:
return data_header


def _populate_lane_dict(count: models.Count) -> Dict[int, int]:
def _populate_lane_dict(count) -> Dict[int, int]:
# e.g. lanes = {1: 435, 2: 436}

lanes = models.Lane.objects.filter(id_installation__count=count).order_by("number")
Expand Down
2 changes: 1 addition & 1 deletion comptages/core/importer_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class ImporterTask(QgsTask):
def __init__(self, file_path: str, count: models.Count):
def __init__(self, file_path: str, count):
self.basename = os.path.basename(file_path)
super().__init__("Importation fichier {}".format(self.basename))

Expand Down
4 changes: 2 additions & 2 deletions comptages/core/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,15 +1014,15 @@ def get_sensor_length(self, lane_id: str):
return query.value(0)
return None

def get_models_by_sensor_type(self, sensor_type: models.SensorType):
def get_models_by_sensor_type(self, sensor_type):
qs = models.SensorTypeModel.objects.filter(id_sensor_type=sensor_type)

result = []
for i in qs:
result.append(i.id_model.id)
return result

def get_classes_by_sensor_type(self, sensor_type: models.SensorType):
def get_classes_by_sensor_type(self, sensor_type):
qs = models.SensorTypeClass.objects.filter(id_sensor_type=sensor_type)

result = []
Expand Down
10 changes: 5 additions & 5 deletions comptages/core/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@


def get_time_data(
count: models.Count,
section: models.Section,
count,
section,
lane=None,
direction=None,
start=None,
Expand Down Expand Up @@ -422,9 +422,9 @@ def get_average_speed_by_hour(


def get_category_data_by_hour(
count: models.Count,
section: models.Section,
category: models.Category,
count,
section,
category,
lane=None,
direction=None,
start=None,
Expand Down
4 changes: 2 additions & 2 deletions comptages/plan/plan_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PlanCreator:
def __init__(self):
self.settings = Settings()

def export_pdf(self, count: models.Count, file_name: str):
def export_pdf(self, count, file_name: str):
current_dir = os.path.dirname(os.path.abspath(__file__))
qpt_file_path = os.path.join(current_dir, os.pardir, "qml", "plan.qpt")
self.layout = PlanCreator.create_layout_from_template(qpt_file_path)
Expand All @@ -26,7 +26,7 @@ def export_pdf(self, count: models.Count, file_name: str):

exporter.exportToPdf(file_name, exporter.PdfExportSettings())

def set_fields(self, count: models.Count):
def set_fields(self, count):
section = models.Section.objects.filter(
lane__id_installation__count=count
).distinct()[0]
Expand Down
Binary file modified test_data/dev.qgz
Binary file not shown.
Binary file added test_data/setup.py.qgz
Binary file not shown.

0 comments on commit b74583a

Please sign in to comment.