Sorting-Algorithms icon indicating copy to clipboard operation
Sorting-Algorithms copied to clipboard

Type annotation for Python based Algorithms

Open UbadahJ opened this issue 5 years ago • 2 comments

Description

Most of the python-based algorithms are not annotated by types as specified by PEP 483 and PEP 484

Using generic types to provide these improvements is an effective way to enforce good practices and provide general documentation for other users quickly.

Implementation

This can be discussed using central generic types with specifically defined types for only those algorithms that work on some certain types (like counting sort) or each file having its independent types

UbadahJ avatar Sep 30 '20 16:09 UbadahJ

@diptangsu What do you think about which approach should be taken?

  • Single file with all generics and specialized one in individual files
  • Each file with its own type defined

Both have there pros and cons and personally I am thinking of going with second option to make the code completely independent at the cost of duplication

UbadahJ avatar Sep 30 '20 18:09 UbadahJ

I also think we should go with each file having its own annotations. Anyone who wants to only look at one code won't have to look elsewhere. And most of the lists would anyway be List[Any] haha.

diptangsu avatar Sep 30 '20 18:09 diptangsu