pyjanitor icon indicating copy to clipboard operation
pyjanitor copied to clipboard

Update Python to be minimum 3.9

Open ericmjl opened this issue 2 years ago • 6 comments

This PR updates our minimum Python version to be 3.9.

Key changes:

  • We matrix Python version testing across 3.9, and 3.10 (current stable version and two before).
  • We note everywhere relevant that the minimum Python version should be 3.9.

ericmjl avatar Aug 21 '22 20:08 ericmjl

@Zeroto521 I just realized this PR might overlap with your other PR #1143. I'll just use the PR to test some syntax things needed to make Python >=3.8 work. After that, we can discard my PR, and you can pick-and-choose whatever changes seem to make sense into your PR.

ericmjl avatar Aug 21 '22 20:08 ericmjl

🚀 Deployed on https://deploy-preview-1157--pyjanitor.netlify.app

ericmjl avatar Aug 21 '22 20:08 ericmjl

Codecov Report

Merging #1157 (57c901b) into dev (78d4297) will increase coverage by 0.00%. The diff coverage is n/a.

:exclamation: Current head 57c901b differs from pull request most recent head f1eb10f. Consider uploading reports for the commit f1eb10f to get more accurate results

@@           Coverage Diff           @@
##              dev    #1157   +/-   ##
=======================================
  Coverage   97.34%   97.34%           
=======================================
  Files          77       77           
  Lines        3240     3244    +4     
=======================================
+ Hits         3154     3158    +4     
  Misses         86       86           

codecov[bot] avatar Aug 21 '22 20:08 codecov[bot]

Directly requires py3.9. Would that be a little bit aggressive? pandas main branch still requires py3.8. I'm okay to deprecate py3.6 and py3.7.

Zeroto521 avatar Aug 22 '22 01:08 Zeroto521

Good question, @Zeroto521. Type annotations in Python 3.9 are more flexible, i.e. we can use built-in tuple or list as types like this:

def func(df, arg1: tuple[int]):
    pass 

We can drop down to Python 3.8 if we fix the types to be:

from typing import Tuple # (and/or List)

def func(df, arg1: Tuple[int]):
    pass

ericmjl avatar Aug 22 '22 01:08 ericmjl

Py3.7+ with __future__ also has that feature.

from __future__ import annotations

int_array: list[int] = list(range(3))
None_or_bool: bool | None = True  # equals to `Optional[bool]`

Zeroto521 avatar Aug 22 '22 02:08 Zeroto521

I also suggest using asottile's pyupgrade to upgrade whatever syntax we can to the minimum version we are supporting. I also suggest sticking to py38 for now instead of jumping straight to py39. py37 EOL is coming this year.

Less manual work :)

thatlittleboy avatar Jan 22 '23 15:01 thatlittleboy

@thatlittleboy I'm in favour of more automation! 😺

Lemme take care of that in a bit.

ericmjl avatar Jan 29 '23 03:01 ericmjl

This PR is going stale. I'm going to close it and re-do it with minimum py38, as per @Zeroto521's and @thatlittleboy's suggestions.

ericmjl avatar Jan 31 '23 21:01 ericmjl