### Install development dependencies Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Navigate to the project directory, create and activate a virtual environment, and install the project with development dependencies. Pre-commit hooks are also installed. ```sh cd eth-abi virtualenv -p python venv . venv/bin/activate python -m pip install -e ".[dev]" pre-commit install ``` -------------------------------- ### Install eth-abi with tools extra Source: https://github.com/apeworx/eth-abi/blob/main/docs/tools.md Install the eth-abi package with the 'tools' extra requirement to access additional functionalities like ABI type strategies. ```bash python -m pip install "eth-abi[tools]" ``` -------------------------------- ### Install eth-abi Package Source: https://github.com/apeworx/eth-abi/blob/main/README.md Install the eth-abi package using pip. This command is used to add the library to your Python environment. ```sh python -m pip install eth-abi ``` -------------------------------- ### Build and test release package Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Before releasing, build the package and install it in a temporary virtual environment to test its functionality. ```sh git checkout main && git pull make package-test ``` -------------------------------- ### Build documentation Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Generate the project's documentation locally to review before publishing. ```sh make docs ``` -------------------------------- ### Clone the repository Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Fork the eth-abi repository and clone it to your local development machine. ```sh git clone git@github.com:your-github-username/eth-abi.git ``` -------------------------------- ### Build release notes Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Generate release notes by specifying the version part to bump. This should be done before bumping the version number. ```sh make notes bump=$$VERSION_PART_TO_BUMP$$ ``` -------------------------------- ### Release new version Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Automate the process of bumping the version, creating a commit and tag, building the package, and pushing to GitHub and PyPI. ```sh make release bump=$$VERSION_PART_TO_BUMP$$ ``` -------------------------------- ### Lint code with pre-commit Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Manually run the pre-commit hooks to enforce code style and formatting across the project. ```sh make lint ``` -------------------------------- ### Show version bump preview Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Preview the effect of bumping a specific version part without making any changes. ```sh bump-my-version show-bump ``` -------------------------------- ### Run all tests Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Execute all tests in the project to ensure code integrity and identify potential issues. ```sh pytest tests ``` -------------------------------- ### Validate newsfragments Source: https://github.com/apeworx/eth-abi/blob/main/docs/contributing.md Ensure that all newsfragments are correctly formatted and ready for release note generation. ```sh make validate-newsfragments ``` -------------------------------- ### Register Custom Null Encoder and Decoder Source: https://github.com/apeworx/eth-abi/blob/main/docs/registry.md Register custom encoder and decoder classes for a 'null' type, where M specifies the number of 32-byte words. Uses a type string matcher function and custom coder classes inheriting from BaseEncoder and BaseDecoder. ```python from eth_abi.registry import registry from eth_abi.base import BaseEncoder, BaseDecoder class EncodeNull(BaseEncoder): word_width = 1 @classmethod def from_type_str(cls, typestr): return cls(word_width=int(typestr[4:])) def encode(self, value): if value is not None: raise ValueError("Value must be None for null type") return b'\x00' * (self.word_width * 32) class DecodeNull(BaseDecoder): word_width = 1 @classmethod def from_type_str(cls, typestr): return cls(word_width=int(typestr[4:])) def decode(self, stream): stream.seek(self.word_width * 32) return None registry.register( lambda x: x.startswith('null'), EncodeNull, DecodeNull, label='null' ) ``` -------------------------------- ### Handle Malformed Strings During Decoding Source: https://github.com/apeworx/eth-abi/blob/main/docs/registry.md Register a custom decoder for strings to handle malformed UTF-8 bytes using different error handling strategies like 'ignore', 'replace', or 'surrogateescape'. ```python from eth_abi.registry import registry from eth_abi.decoding import StringDecoder # Example: Registering to ignore errors registry.register_decoder(StringDecoder(errors='ignore'), label='string') # Example: Registering to replace errors # registry.register_decoder(StringDecoder(errors='replace'), label='string') # Example: Registering to use surrogateescape # registry.register_decoder(StringDecoder(errors='surrogateescape'), label='string') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.