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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

ry_cli-0.4.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.4.0-py3-none-musllinux_1_2_aarch64.whl (1.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

ry_cli-0.4.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.4.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (1.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

ry_cli-0.4.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.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

ry_cli-0.4.0-py3-none-macosx_11_0_arm64.whl (1.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ry_cli-0.4.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.4.0.tar.gz.

File metadata

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

File hashes

Hashes for ry_cli-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e51dd3651bf9e513fabe33de19a071f25cbbddbd07160ff731a649f78d7e1d9d
MD5 566a7293c67b317d485944b83f3cc756
BLAKE2b-256 371612cf68564345d87d151b1dc2a1ff7699a51ebc6a560b660efc43fd7655a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.4.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.4.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 ea72ef8b8c3cb5c1e47ccec97339d8b983504984119c4d9fcb7e3d7607ccd348
MD5 d84826dd7419bf0463bc5173e41ec264
BLAKE2b-256 218b30309a3300535e6c59c214d26df327e9cc63b9228850383e0deeb60757b0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.4.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.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a7520c669372cdad1c081a89ee1663b9048083bcc4fe626daf0f0422634795fc
MD5 a0d053d00ee2fc9b4bf1a694c22583e6
BLAKE2b-256 762b20a209f03bb6cbb8695e9bc45adbed8d58932399fc9530814d6b2f2df554

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.4.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.4.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 a77558531c2873a5396dc42ea0f16972acdcbdaf8aeb18f7cbf92c940e5a6bf0
MD5 50d41107a5f6d2f94fa5ec9e12e97492
BLAKE2b-256 87653322c9deb4585296e18214f587a3d25e75b37282fa57c9014ad850446ad5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3389984e26892bbfe614f6fa38531ca2ca6086de3b1fc17a0243eb95c8dd14f2
MD5 33b860e76d7b3fe83e4707b2ec656f3d
BLAKE2b-256 827989c03257666f2c9cabda4c817ba22d40a745a849c7efb798d147ebb00d46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 129fa8d938b225b2cfaea0a5961770cc11de1a7158c32acca2f1ea4c806c057a
MD5 7c0a8cf13ea354b7d4857d14c0a16771
BLAKE2b-256 16d07a9e2e731f98fd8a2cc9e8f916a1b0ee2e12516b9a78e21ad8deb8f5b4cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e41958bede447e133b1d0b13bf1b5e6acf1bba58dd9f8614fc17c95affdaedf
MD5 091c0e5e2b12b45016d0f4eff4cfdf16
BLAKE2b-256 0be86dc9be51d2cb454d955c612a9d39a81f086e64145f1a375cc75a5667ca0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 5e47c5d1df04e683774398781d746ab0cb303b95833a45630eaabb0a5ee296c0
MD5 7b8f3cb29e2b1343f8ba571decc15ff8
BLAKE2b-256 fce2eefa46c4b1b28fb8e5a40b7d11e471f653b503f13f678a32c0d478d50e16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 95127d03ac4b09ff7fc9454fb4afd15e6e97f7ccfe5159cbab6c1885e275746d
MD5 7b7fcd9665b30b0931ad81b0e847cea0
BLAKE2b-256 1506c9466835a59750b9d66c069b9960113ccc9023ff895f76e47722b55e0c38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 03559134a31907bec50366bd8def039d8f0caa6fa7b66bb55bd7bf77cae479a4
MD5 c2766e1fd1ceff7d6c2ab52718f86142
BLAKE2b-256 9d9c3f79cbb06be3c10a4fffbbc588135d88ad7d5df6fb48b0f2f017863b82e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec6af88f24d8141b070596199b445940a825bcd472c51281d120ef90ee7b5a7e
MD5 9d9dfef4fd071fdf68105f08ea6332db
BLAKE2b-256 22cb8520e62c5b00bec5144cf5f6a4ec7dbdb0b426af8afe3c1abd6717f37cd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.4.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 695a428aa1ef7ed042a8a0a64a67b618db449ecf1e879bb9acd574cad3aeda59
MD5 fb137d82fe9ca5a5189cbc6081da77fe
BLAKE2b-256 5d7e1958a77fd1e0bf7c200c35258a1d82f2f8a38b934fc5773e12b32d07c9b8

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