Skip to main content

Vyper formatter

Project description

image

Mamushi

image Build Status codecov License: MIT Code style: black

Mamushi is a fork of the popular Black formatter adapted to the Vyper programming language. Mamushi reformats your Vyper contracts in a readable and consistent way.

Installation

pip install mamushi

Usage

Search all *.vy files and overwrite them after formatting:

mamushi

Specify a list of *.vy files or directories and output to console after formatting:

mamushi [SRC]

Output the result to console instead of overwriting:

mamushi --in-place False

Notes

Line length

The default line length is 80. Line length can be adjusted by using the --line-length option.

AST Safety

By default, mamushi will compare the AST of your reformatted code with that of the original to ensure that the changes applied remain strictly formal. The option can be disabled with --safe False to speed things up.

Trailing commas

When handling expressions split by commas, mamushi follows Black's default behavior.

Mamushi also uses Black's magic trailing comma to give user the option to collapse a comma-separated expression into one line if possible. If a trailing comma is added, mamushi will always explode the expression. This can have important consequences for the commenting of your code. Consider the following two examples:

This code snippet:

self.b(0, # amount to send
       msg.sender, # sender
       True, # refund ?
        )

formats to the following with a trailing comma after the last argument (True):

self.b(
    0,  # amount to send
    msg.sender,  # sender
    True,  # refund ?
)

but if the trailing comma is removed, the line will be collapsed to:

self.b(0, msg.sender, True)  # amount to send  # sender  # refund ?

Future developments

  • Multiprocessing when processing multiple files
  • Configuration files
  • Improve Windows compatibility
  • Handle versioning of Vyper/lark grammar
  • Refactoring comment handling in the parser
  • Add .gitignore / exclude / include support

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

mamushi-0.0.4a3.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

mamushi-0.0.4a3-py3-none-any.whl (47.9 kB view details)

Uploaded Python 3

File details

Details for the file mamushi-0.0.4a3.tar.gz.

File metadata

  • Download URL: mamushi-0.0.4a3.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.8

File hashes

Hashes for mamushi-0.0.4a3.tar.gz
Algorithm Hash digest
SHA256 2423a88c324405cff3fd2d6ff63140f57b5575bb5b315be9ae3e6b6c6d8081de
MD5 e1f6b74bf1f1a085b00bac509bedb893
BLAKE2b-256 197577e19c9102b9be5afc584a0a6aff52f2fca57f3663bdfccb3c26fb958e52

See more details on using hashes here.

File details

Details for the file mamushi-0.0.4a3-py3-none-any.whl.

File metadata

  • Download URL: mamushi-0.0.4a3-py3-none-any.whl
  • Upload date:
  • Size: 47.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.8

File hashes

Hashes for mamushi-0.0.4a3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2c0edbb75c218d354105b3b4d75a5f95a23f3ce02919b81cf123aca0ecf374b
MD5 f306610f1913c57e31c9ae9a34c7b200
BLAKE2b-256 2c45a5ad13934b7370bbcb098d2f69ff98cba5a7d9f2b9121cec9a06e2571c5d

See more details on using hashes here.

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