[Freeciv-tickets] [freeciv] #44615: generate_packets.py: Add type annotations

Back to archive index
OSDN Ticket System norep****@osdn*****
Tue Jun 7 02:10:15 JST 2022


#44615: generate_packets.py: Add type annotations

  Open Date: 2022-05-15 16:33
Last Update: 2022-06-06 19:10

URL for this Ticket:
    https://osdn.net//projects/freeciv/ticket/44615
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44615

---------------------------------------------------------------------

Last Changes/Comment on this Ticket:
2022-06-06 19:10 Updated by: alienvalkyrie

Comment:

With the decision in #44735 to increase the minimum Python version for freeciv-3.2 to Python 3.5, I will be using the typing module for abstract base types, typevars etc.; however, I'll still stick to aforementioned (string-wrapped) use of newer, preferred typing syntax, so "list[int | float]" instead of typing.List[typing.Union[int, float]] – the only point in evaluating annotations at runtime would be to check that they are well-formed, which is already being done by the static type checker.

---------------------------------------------------------------------
Ticket Status:

      Reporter: alienvalkyrie
         Owner: alienvalkyrie
          Type: Patches
        Status: Open [Owner assigned]
      Priority: 5 - Medium
     MileStone: 3.2.0
     Component: Bootstrap
      Severity: 5 - Medium
    Resolution: None
---------------------------------------------------------------------

Ticket details:

Part of #43927. Add PEP 484-style type annotations for use with IDEs and static type checkers.
Problem: Python 3.4 has no special support for type annotations, beyond allowing function argument and return type annotations. In particular, the typing module is only introduced in Python 3.5, and variable annotations only in Python 3.6. 
Potential solutions:
Leave out any annotations that would require typing 
In particular, this means no generic functions (which some helper functions could be)
Add workaround code to use typing only when available, while maintaining 3.4 compatibility 
This might add a certain amount of noise to the script
Increase the minimum supported Python version to 3.5 or even 3.6
The first of these options is likely the best one that doesn't require changing dependency versions.

-- 
Ticket information of Freeciv project
Freeciv Project is hosted on OSDN

Project URL: https://osdn.net/projects/freeciv/
OSDN: https://osdn.net

URL for this Ticket:
    https://osdn.net/projects/freeciv/ticket/44615
RSS feed for this Ticket:
    https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=44615



More information about the Freeciv-tickets mailing list
Back to archive index