Tool to convert Python code to work with older versions
Project description
Python3.11などの新しいバージョンのコードを、古いバージョンで動作するように変換するツールです。
あくまでも動作するように小手先の変換を施すだけであって、複雑なパターンの変換や厳密な等価性が必要な場合には使用できません。 また、当然ですが可読性はある程度失われます。
具体的には、以下のような変換を行います。
- 代入や関数定義の型アノテーションを文字列リテラルに置き換える
- 旧バージョンに存在しない要素の
from typing import
を削除する alias: TypeAlias = SomeType
という形のTypeAlias
の定義をする代入文の右辺を文字列リテラルに置き換える- match文をif文に変換する(複雑なものには未対応)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
compatibilityer-0.3.7.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for compatibilityer-0.3.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e38b8c6a3bbe057997dcb201f7421553f78d2e8f46d60231ef917af0f8b337e5 |
|
MD5 | aa0e2a81bddd5f9ec3f9fe0df0f063b2 |
|
BLAKE2b-256 | 0de6dc42f399d8b348931f91d2b5feb4ac50f53c9925230cb117a02555982c6d |