Skip to content

Add type hints from typeshed #203

@hugovk

Description

@hugovk

Let's add type hints to PrettyTable.

The good news is much of the work is already done because typeshed has .pyi signature stubs:

And here are some resources for automating the conversion of stubs into inline annotations:

Tasks:

  • Add this to .pre-commit-config.yaml so pre-commit adds this import to Python files and we can use newer typing Syntax on older Python 3.7:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 3dbc9c0..316e7f5 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -15,6 +15,7 @@ repos:
     rev: 5.10.1
     hooks:
       - id: isort
+        args: [--add-import=from __future__ import annotations]
 
   - repo: https://github.com/PyCQA/flake8
     rev: 5.0.4
  • Apply the type hints from typeshed to this repo
  • Add mypy via pre-commit and make mypy pass (can be follow-up PR if there's much to do)
  • Add py.typed and "Typing :: Typed" Trove classifier

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions