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

Uploaded Python 3Windows ARM64

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

ry_cli-0.2.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.2.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.2.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.2.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.2.0-py3-none-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

ry_cli-0.2.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.2.0.tar.gz.

File metadata

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

File hashes

Hashes for ry_cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7b1c752c798c312ca5058ad9d407019d3f0782ca489d9503321935999365b818
MD5 519b1a95ad24e6caeb5d6cc0731f1957
BLAKE2b-256 8000f09b09521561b843d81ec70000c3b0d2d1c52e5d076477d15a4650a6e3d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.2.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.2.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 b05b328020ae52cf30db1073935b780ead25e4d0ab780f31b6023d65887cfbeb
MD5 9f3ae17ba6b6d7acb16d7318b0cba14f
BLAKE2b-256 d7e963e4f778d5d605433cfcce9778cf6ddd26afb46b80529b5cd0cda8aab4c8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.2.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.2.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f6b591ca73b4879a0e5fbf813ea4620a96e875bcab7ec2de7f54618677895c92
MD5 656fe6f76e1e4ec66efdcbe91fa3bfd1
BLAKE2b-256 11b6fa438c93cc797759c5417563194cb876d77311ce5f9b31464646f805ed59

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ry_cli-0.2.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.2.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 2a6936c2d4800bc35654f980cbea872e38b2aa9f29aac6b94c3bc7df98e8e79b
MD5 333729d2f3c842492c8b3e062b3630b4
BLAKE2b-256 b094d7b569b8a919fb32e3c7ca1691de90c8b5c00c95e5e467b2188f0b0dde54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7601ca0799c4e1f83da00fc8c79505e6df629a99b72e97accf0880c9686c5bca
MD5 dc1e494cff33b724c7177e377be7d936
BLAKE2b-256 d04fdd00872a1f957cf973fdab4c27d8492e110e7c41fc1ee1e47224d89f9e8e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f57caeb07eb356a508ca345767923664ea9d81e424015ac55acce59461d5e1e4
MD5 bbae3087fdf162e51a95c6bb908d755a
BLAKE2b-256 3ef98e2f4bc3bce4e04c327a5865122bf75c0529dfc3ca258ab5d34c560284e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 897f4b6a9c0e82d45bd55330dab3c1a5c38e0d0325fa8df72f8f0169358e136f
MD5 532dd121b69078904272ba4bde2a70d7
BLAKE2b-256 c58a7cd7cf4b922a578b801788c0f11ce75c1f1126b14604a114e14d0125d055

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1cb870d12a325296640ce43feb4c33d22ff416d5110d70a6dd766a162686c46f
MD5 6fa6cee80e9fb35ffda62d12148780c5
BLAKE2b-256 76f5a8b9ada130a56efd0705786c5d69f7e08877f39c6beed529fb85c4b9b454

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 ac07571b00b770807e00287a945e9899f5007ed08058687a7d58b419663a8f46
MD5 0dc94311885f6a12dbb7da995194586c
BLAKE2b-256 fb52da44bdc0170cb40737bcec3bfd2d03e8bc6c375f1d3b3734e2b645b45b70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c57c3ef54be665afe75c26227f4853cc07f7039f3531b8da3862adbee50ca57a
MD5 8e031a37681f3e8770a8e0525a24bee2
BLAKE2b-256 7a85346b2dba922d7c4143582072babc066eba29ae451d82f5d8760edc5df387

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 75abca3b366e5f72d9ee26d520fb707d67b390d4180ea9e26954d50fe7811149
MD5 58c183f2f2f805721f6e1b3a041911a2
BLAKE2b-256 fb2e0e76b7c6c17b7a7a2b386230543a4c039b0dfefbb2219b1e97ca079e8f79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ry_cli-0.2.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8d66057e0b3ee274e7dd2cdd7d6ae2ceb1c223cf64ae963ad46e8f9bb7088b2a
MD5 b53fac60c0b06f5548beea01fc3a95f5
BLAKE2b-256 66175e7f88bb8683222d2a10dcc6228f40a869a30c050fcd6714280ca39d08b3

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