Skip to main content

Repeat yourself - transform Python code using regex rules

Project description

ry logo

ry stands for "repeat yourself" - the opposite of DRY.

Inspired by unasync, but built from the ground up for inline transformations and more flexible configurations.

Ry transforms the Python code using regex rules. Originally built to simplify maintaining dual async/sync codebases, but works for any pattern-based transformations.

Comes with a package system where you can define reusable sets of rules. Have a built-in std package with all standard rules (like async def to def, etc), and you can create your own packages for your specific transformations.

Inline Transformations

Ry can transform not only whole files, but also specific lines or blocks of code based on inline comments.

class Response:
  
    async def aclose(self) -> None:  # unasync: generate
        if self._stream_to_close is None:
            return

        if not isinstance(self._stream_to_close, AsyncClosableStream):
            raise AsyncSyncMismatchError("Can't call `aclose` in this context")

        await self._stream_to_close.aclose()
        self._stream_to_close = None

+    def close(self) -> None:  # unasync: generated
+        if self._stream_to_close is None:
+            return
+
+        if not isinstance(self._stream_to_close, AsyncClosableStream):
+            raise AsyncSyncMismatchError("Can't call `close` in this context")
+
+        self._stream_to_close.close()
+        self._stream_to_close = None

Usage

Validate without modifying files:

ry src/

Fixes all the fixable issues:

ry --fix src/

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

ry_cli-0.1.0.tar.gz (9.2 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ry_cli-0.1.0-py3-none-win_arm64.whl (1.1 MB view details)

Uploaded Python 3Windows ARM64

ry_cli-0.1.0-py3-none-win_amd64.whl (1.2 MB view details)

Uploaded Python 3Windows x86-64

ry_cli-0.1.0-py3-none-win32.whl (1.1 MB view details)

Uploaded Python 3Windows x86

ry_cli-0.1.0-py3-none-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

ry_cli-0.1.0-py3-none-musllinux_1_2_aarch64.whl (1.4 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ry_cli-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

ry_cli-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (1.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

ry_cli-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

ry_cli-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ry_cli-0.1.0-py3-none-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ry_cli-0.1.0-py3-none-macosx_10_12_x86_64.whl (1.4 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file ry_cli-0.1.0.tar.gz.

File metadata

  • Download URL: ry_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 9.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for ry_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ff2066b9c6f758bf3ae19d905f8ecf1c0f1592b8e5c1862ef0f6ba2e23f0375a
MD5 c49ce2115c1fbf262706069b1bd282f9
BLAKE2b-256 b02a1a5d000cc309cf9269e9f305618d1bd6950c850f92d0ac7c18001f81bd72

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: ry_cli-0.1.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for ry_cli-0.1.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 fcc50d11a896607bb72bdd6ac896367f4e8b6719023ba059cf5fb74fdc321242
MD5 fc75d27308970b5d20743eb059ce16d2
BLAKE2b-256 50fcfc8ae49143e8846d3d3c80fdd236631e2239b527ed688a8f7ac849e3c277

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: ry_cli-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.2 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for ry_cli-0.1.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5bfc513dc23e49471ceec75d981616cd355e338c0683a98db1c822be6fd2afb1
MD5 eaa6e7a12e6d10f6b718e8eb2c5640d0
BLAKE2b-256 8341778bf2650efb5e3692b45c8df80752ac01b54b4fb330a06caba6df5ce641

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-win32.whl.

File metadata

  • Download URL: ry_cli-0.1.0-py3-none-win32.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for ry_cli-0.1.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 8ab91c4a02ce36c3ff9a9a87fb2b2960b2b9d8fd3935fc8e48321b0d952572c6
MD5 8a25b654a01bba79aceba8acd010c15f
BLAKE2b-256 a7f97b5419b733ab58510fae5a255d5b9aef2dc18b0cf0c2b6f1a71309ca297f

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8c0d3a63c45754c43a52583862805f9fe879fc4915dda26536e2858b89d61795
MD5 b54e3d130816bbf52c5acbaec76559e4
BLAKE2b-256 2cef232418d1e447636aa853d2cf0465ce332ccd3742e735a6fdc60f22419687

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2883708e6b1f43eece728b996456471b97fdebece15d35ea06b2dc4949faad53
MD5 5c6e1b7770b8ad41db77374b2d2117af
BLAKE2b-256 f00dd31407459743f15a1504e7ce49bb7172bdfb429946eb2c8af8f596ce9da3

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb97fef8ae51b1953474981f93722c5f5a45fdbbc8bb2a550d693dde01485fe0
MD5 ebef0c1b67815be7dd7ead643c8c99b2
BLAKE2b-256 9a0f4e4e5b192a7aed076a7581ac4ae004f48c718211df62fcbe1c4baa23a6e0

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 bc4df1fc1be35f1351149c98ac3f884a254a32517c5655fbfdfd161e0254e75a
MD5 4a3e7bcf70378d7c46890dfb55925305
BLAKE2b-256 f61e13a70d90dfdcd31df701be788a2fc4fc1bc4e7ff0e6c663b5f6a24f28880

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 2e38a246217fff6763fcd3ec890e900d167ca9d025555f47b432bfe54d1ee443
MD5 6d75aeb80403140307f6063fb89ead4b
BLAKE2b-256 6b9be26bcb82c9a0138bdffeff552265f34387e1a784eef9730516355975ea69

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4a60e6c77af796433b4e8639329bb7e73fe978caff1804795ed19adad904d90d
MD5 e3337013a6c5cdbae6139efa9672ea5d
BLAKE2b-256 eb972daf29203cfc25c69136ce32ceb7a6d3c36bf25bcb6345c5cbb39cba2e35

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4481bfd5067cebcd4b81dcc45100f81796f9d763c2e1f814286ddca8a8faccfa
MD5 4ab74c12e7df2f35d25069d636f1124f
BLAKE2b-256 d356e27c076d65f0f663c55b715c1053db9cabba5e70b4ed8af0e7eab764367a

See more details on using hashes here.

File details

Details for the file ry_cli-0.1.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ry_cli-0.1.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 cad26002cfa93ffd60bd2820a2fa71ebabbf05816404aa26a1bc7d38839f82be
MD5 5fb1c288c2fcffc1a64b0d39acc4ea38
BLAKE2b-256 2ec6eb2b24d18471c329d27972782133cbd7bbba57312a0318f5fc18fb1a6590

See more details on using hashes here.

Supported by

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