From cbf7323ba733381870358a3b584fd3ac683ed675 Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Mon, 20 May 2024 19:10:28 +0200 Subject: [PATCH] Build the real signature for the main functions and remove useless import --- src/parliamentarch/__init__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/parliamentarch/__init__.py b/src/parliamentarch/__init__.py index 1f866db..7abfe80 100644 --- a/src/parliamentarch/__init__.py +++ b/src/parliamentarch/__init__.py @@ -1,5 +1,4 @@ from inspect import signature -from io import TextIOBase from .geometry import get_seats_centers from .svg import SeatData, dispatch_seats, get_grouped_svg @@ -7,8 +6,8 @@ __all__ = ("get_svg_from_attribution", "write_svg_from_attribution", "SeatData") -_GET_SEATS_CENTERS_PARAM_NAMES = {k for k, p in signature(get_seats_centers).parameters.items() if p.kind==p.KEYWORD_ONLY} -_WRITE_GROUPED_SVG_PARAM_NAMES = {k for k, p in signature(get_grouped_svg).parameters.items() if p.kind==p.KEYWORD_ONLY} +_GET_SEATS_CENTERS_PARAM_NAMES = {k: p for k, p in signature(get_seats_centers).parameters.items() if p.kind==p.KEYWORD_ONLY} +_WRITE_GROUPED_SVG_PARAM_NAMES = {k: p for k, p in signature(get_grouped_svg).parameters.items() if p.kind==p.KEYWORD_ONLY} def get_svg_from_attribution(attrib: dict[SeatData, int], **kwargs) -> str: nseats = sum(attrib.values()) @@ -21,4 +20,13 @@ def get_svg_from_attribution(attrib: dict[SeatData, int], **kwargs) -> str: seat_centers_by_group = dispatch_seats(attrib, sorted(results, key=results.__getitem__, reverse=True)) return get_grouped_svg(seat_centers_by_group, results.seat_actual_radius, **write_grouped_svg_kwargs) +_sig = signature(get_svg_from_attribution) +_attrib_param = _sig.parameters["attrib"] +get_svg_from_attribution.__signature__ = _sig.replace(parameters=( + _attrib_param, + *_GET_SEATS_CENTERS_PARAM_NAMES.values(), + *_WRITE_GROUPED_SVG_PARAM_NAMES.values() +)) +del _sig, _attrib_param + write_svg_from_attribution = write_from_get(get_svg_from_attribution)