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.

Installation

pip install ry-cli

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.3.0.tar.gz (979.4 kB 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.3.0-py3-none-win_arm64.whl (1.1 MB view details)

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

ry_cli-0.3.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.3.0-py3-none-musllinux_1_2_aarch64.whl (1.4 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ry_cli-0.3.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.3.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.3.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.3.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.3.0-py3-none-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ry_cli-0.3.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.3.0.tar.gz.

File metadata

  • Download URL: ry_cli-0.3.0.tar.gz
  • Upload date:
  • Size: 979.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for ry_cli-0.3.0.tar.gz
Algorithm Hash digest
SHA256 eb785284792f7026824531ec242f7e237861a69ce6a7a28f36997ef57d749702
MD5 0f91e50930d8f5f8f3ca48bfdd2fe388
BLAKE2b-256 04116c35c1e05e996bdf222f5c23f0bc589edc71f7ff33040b6d202c756250eb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.3.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.13.1

File hashes

Hashes for ry_cli-0.3.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 0a53df2640641937012eea6b6ad28a393b1c42ac9397ffd95e5b142e1ac6114c
MD5 2255f7bbe3f04a779094b6439663e114
BLAKE2b-256 edc1ea97c508960191edfd33fce835ec186ef52c067faa3a77f155e504bd9177

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.3.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.13.1

File hashes

Hashes for ry_cli-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 753c429119ab754c56f9787a9fefc80bf4dc2fe6af7c6ec5c9cdd8f362fc531d
MD5 85c2984d5621a8d2bafbf01bee0894cd
BLAKE2b-256 2c62ef895c1be28b21dec293dd95044d51b7f3920b4f87ac72299a785716fdbc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.3.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.13.1

File hashes

Hashes for ry_cli-0.3.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 99511755c250ef4fb5a8cde16400403411d84196f792fef0bf91799f18085d70
MD5 7eb0003db1ab326fede33418784d5f1f
BLAKE2b-256 9580d83932d266f9f84d7333a20cae0656bf919bb1c5719a15619c12ab220195

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2c9136a4f169daff2d3278d53660d9151e814b4cc40b381b15233c4b4379c2bd
MD5 392d9967890467b196710b129cc70c77
BLAKE2b-256 2bc77a49c1b8b79c8b96de8999a588e8892751829504c9b24b627eaf2c642439

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 56d07419ed999a122de3b048c852db038a2df7660625bb6d9ef12fc28670bb33
MD5 b45db8706d23b5ddad01c5404464834f
BLAKE2b-256 c4e863069ad088aab2ca6f26752199306fe7e76b6cb7867e4c3d8784cd4fad34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 689d9fb7cf27d9add956b1e87c32bc231b4a324eed0b00531e662db148f101b0
MD5 c7936df8ec111ce2f497c44920dea1e1
BLAKE2b-256 88effdeda68c2d37582252a19954cd04e8a74a51c453980db56d71e34e696525

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b1fb8fbaf0d274baa30256d3fb33b157c0f3429abf14d8a144899b7b52afa9c7
MD5 bd7fc815bf98e20005ce7d503c96599e
BLAKE2b-256 9c8ba485a86f52fc926cbf17d09e31275bd4f11e10d68daa754995d4145acb28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 c3b136ce39c653107a7b44e86f3562ae8d3fcc8779762dee77c11595f5783448
MD5 6a66636f27bc0ea802bc57a5de540096
BLAKE2b-256 f302fa336f2b245d845f534f1533ae9a60da6648db1c56c3cb6f7099d93c293b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ec92a67c1c29264de97cce18844659020d8c9561cbd23c0e414be233a7a175f3
MD5 6a1a99133d35d67b0c7dd0d78c4bee55
BLAKE2b-256 390aa5868c6135c6bcd1ff63734e39fb2899f86033292e5b37e9b76e20ea936c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a65b6cd2e5a15fc1cc3992718dd6f171dfef518c0a57fb920648e720cdab1d09
MD5 a4a252b4637f22a57feaa7de6d4c149e
BLAKE2b-256 ab9c7fb106011b1a1dc5458083e2d0782c597813dd6a3f1bc02d565652cc2ee7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9b4a046c55bd403142bf6dfdd2390cdc42d8aa327f59876c11d33442304b3f3c
MD5 a737f6f839908d52e760a37d6ed289af
BLAKE2b-256 88e8655799f416fedb9724e11bcffd403e9967acc9a551e9582c7e47e0efa043

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