Skip to content

DeprecationWarning for distutils in Python 3.10 (will be removed in Python 3.12) #906

Closed
@nayaverdier

Description

@nayaverdier

What were you trying to accomplish?

Run tests utilizing aws-lambda-powertools.

Expected Behavior

No DeprecationWarning to appear.

Current Behavior

When running tests (specifically using pytest) that import aws_lamdba_powertools, a DeprecationWarning appears.

.../aws_lambda_powertools/shared/functions.py:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.util import strtobool

Possible Solution

The only function used out of distutils is strtobool, and it is only used in one place, so that logic can simply be copied into the resolve_truthy_env_var_choice function in aws_lambda_powertools.shared.functions.

Steps to Reproduce (for bugs)

  1. Use python3.10
  2. Activate a new venv (python3.10 -m venv .venv and . .venv/bin/activate)
  3. pip install aws-lambda-powertools pytest
  4. echo "import aws_lambda_powertools" > reproduce.py
  5. pytest reproduce.py

Environment

  • Powertools version used: 1.22.0
  • Packaging format (Layers, PyPi): PyPi

This warning appears in development workflows, but will be eventually breaking when Python 3.12 is released.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions