Flake8 plugin that lints contracts written in python on Xian-network
python>=3.8, flake8>=3.7
You can decide to create a virtual environment for this or go ahead with the following instructions. (Kindly google how to create a python virtual environment if you want to do so)
- Install Flake8 if you haven't
pip install flake8
- Clone this repo and move into flake8-contracting folder
git clone https://github.com/KELs7/flake8-contracting.git
cd flake8-contracting
- Install Flake8-contracting
pip install -e .
- Check that Flake8-contracting is properly installed
flake --version
You should see something similar to this (if you installed Flake8 v7.0.0)
7.0.0 (flake8-contracting: 0.1.0, mccabe: 0.7.0, pycodestyle: 2.11.1, pyflakes: 3.2.0)
- When you want to lint your contract code from the command line, do
flake8 path/to/contract.py
Flake8 will flag any line of code containing any of the below as undefined with error code F821
- ForeignHash
- Hash
- Variable
- random
- @construct
- @export
- ctx
- now
To avoid this add the comment # noqa: F821 to the line of code containing any of the above.
Example:
settings = Hash(default_value=0) # noqa: F821Ensure there is a single space between # and noqa and a double space between : and the error code F821
- ignore as much errors that might conflict with the linter
- list all available error codes in README
- probably add tests
- ensure each reported error has the correct column offset value