Skip to main content

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


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.8.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

compatibilityer-0.3.8-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page