noatamir/pyladies-workshop

Typing: Narrow down types of arguments (Series)

Closed this issue · 2 comments

phofl commented

We prefer using Literal["a"] | Literal["b"] instead of str. Look into the documentation what is allowed and the narrow the types down appropriately. Generally, we probably already have type definitions in pandas/_typing.py like NaPosition for the first item in the list below.

You can locate the appropriate file through searching for class Series in the repository.

Series methods:

  • Specifykind and na_position more precisely in sort_values (can look at sort_index, it is already done there)
  • Specify keep for nsmallest and nlargest more precisely

I'm doing sort_values
Edit: it's here

dong the second one