Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,28 @@ jobs:
python -m pip install "tox>=4.10"
- run: |
python -m tox run -r

windows:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
toxenv: [core, lint]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "tox>=4.10"
- name: Test with tox
shell: bash
run: |
python_version="${{ matrix.python-version }}"
toxenv="${{ matrix.toxenv }}"
echo "TOXENV=py${python_version}-${toxenv}" | tr -d '.' | tee -a "$GITHUB_ENV"
python -m tox run -r
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ coverage.xml
# Sphinx documentation
docs/_build/

# Generated HTML files
*.html
!docs/_build/html/*.html

# PyBuilder
target/

Expand Down
19 changes: 15 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,19 @@ repos:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/northisup/pyright-pretty
rev: v0.1.0
- repo: local
hooks:
- id: pyright-pretty
args: [--show-summary]
- id: mypy-local
name: run mypy with all dev dependencies present
entry: mypy -p multiaddr
language: system
always_run: true
pass_filenames: false
- repo: local
hooks:
- id: pyrefly-local
name: run pyrefly typecheck locally
entry: pyrefly check
language: system
always_run: true
pass_filenames: false
16 changes: 15 additions & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
Steven Buss <[email protected]>
Alexander Schlarb <[email protected]>
Fred Thomsen <[email protected]>
Jesse Weinstein <[email protected]>
Alexander Schlarb <[email protected]>
mhchia
acul71
arcinston
pacrob
raulk
robzajac
zixuanzh
hugovk
justheuristic
manusheel
rodvagg
venkat
fredthomsen
web3-bot
63 changes: 49 additions & 14 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Report bugs at https://github.com/multiformats/py-multiaddr/issues.
If you are reporting a bug, please include:

* Your operating system name and version.
* Python version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Expand Down Expand Up @@ -62,27 +63,33 @@ Ready to contribute? Here's how to set up `multiaddr` for local development.
1. Fork the `multiaddr` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/multiaddr.git
$ git clone [email protected]:your_name_here/py-multiaddr.git

3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
3. Install your local copy into a virtual environment::

$ mkvirtualenv multiaddr
$ cd multiaddr/
$ python setup.py develop
$ python -m venv venv
$ source venv/bin/activate # On Windows: venv\Scripts\activate
$ pip install -e ".[dev]"

4. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::
5. When you're done making changes, run the development workflow::

$ flake8 multiaddr tests
$ python setup.py test
$ tox
$ make pr

To get flake8 and tox, just pip install them into your virtualenv.
This will run: clean β†’ fix β†’ lint β†’ typecheck β†’ test

Or run individual commands::

$ make fix # Fix formatting & linting issues with ruff
$ make lint # Run pre-commit hooks on all files
$ make typecheck # Run mypy and pyrefly type checking
$ make test # Run tests with pytest
$ make coverage # Run tests with coverage report

6. Commit your changes and push your branch to GitHub::

Expand All @@ -101,13 +108,41 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4+ and PyPy3. Check
https://travis-ci.org/multiformats/py-multiaddr/pull_requests
and make sure that the tests pass for all supported Python versions.
3. The pull request should work for Python 3.10+ (Python 3.9 support was dropped).
4. All type checking must pass (mypy and pyrefly).
5. All pre-commit hooks must pass.
6. Code must be formatted with ruff.

Development Workflow
--------------------

The project follows a py-libp2p-style development workflow:

1. **Clean**: Remove build artifacts
2. **Fix**: Auto-fix formatting and linting issues
3. **Lint**: Run pre-commit hooks
4. **Typecheck**: Run mypy and pyrefly
5. **Test**: Run the test suite

Use ``make pr`` to run the complete workflow.

Release Notes
-------------

When contributing, please add a newsfragment file in the ``newsfragments/`` directory.
See ``newsfragments/README.md`` for details on the format and types.

Tips
----

To run a subset of tests::

$ python -m unittest tests.test_multiaddr
$ python -m pytest tests/test_multiaddr.py

To run with coverage::

$ make coverage

To build documentation::

$ make docs
17 changes: 17 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,23 @@ History

.. towncrier release notes start

0.0.10 (2025-6-18)
------------------

* Fix Type Issues and add strict type checks using Ruff & Pyright
* Spec updates, Python 3.4- unsupport & custom registries by @ntninja in #59
* add quic-v1 protocol by @justheuristic in #63
* Fix/typecheck by @acul71 in #65
* chore: rm local pyrightconfig.json by @arcinston in #70

0.0.9 (2019-12-23)
------------------

* Add Multiaddr.__hash__ method for hashable multiaddrs
* Add onion3 address support
* Fix broken reST and links in documentation
* Remove emoji from README.rst

0.0.7 (2019-5-8)
----------------

Expand Down
10 changes: 7 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
include AUTHORS
include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include LICENSE-APACHE2
include LICENSE-MIT
include README.rst

recursive-include tests *

global-include *.pyi

recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat
prune .tox
prune venv*
35 changes: 32 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean-pyc clean-build docs clean
.PHONY: clean-pyc clean-build docs clean help pr
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
Expand All @@ -11,6 +11,26 @@ endef
export BROWSER_PYSCRIPT
BROWSER := python -c "$$BROWSER_PYSCRIPT"

help:
@echo "Available commands:"
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "clean-test - remove test artifacts"
@echo "clean - run clean-build, clean-pyc, and clean-test"
@echo "setup - install development requirements"
@echo "fix - fix formatting & linting issues with ruff"
@echo "lint - run pre-commit hooks on all files"
@echo "typecheck - run mypy and pyrefly type checking"
@echo "test - run tests quickly with the default Python"
@echo "coverage - run tests with coverage report"
@echo "docs-ci - generate docs for CI"
@echo "docs - generate docs and open in browser"
@echo "servedocs - serve docs with live reload"
@echo "authors - generate AUTHORS file from git"
@echo "dist - build package and show contents"
@echo "notes - consume towncrier newsfragments and update release notes (requires bump parameter)"
@echo "pr - run clean, lint, and test (everything needed before creating a PR)"

clean: clean-build clean-pyc clean-test

clean-build:
Expand All @@ -32,16 +52,22 @@ clean-test:
rm -fr htmlcov/

setup:
pip install -r requirements_dev.txt
pip install -e ".[dev]"

lint:
pre-commit run --all-files

fix:
python -m ruff check --fix

typecheck:
pre-commit run mypy-local --all-files && pre-commit run pyrefly-local --all-files

test:
python -m pytest tests

coverage:
coverage run --source multiaddr setup.py test
coverage run --source multiaddr -m pytest tests
coverage report -m
coverage html
$(BROWSER) htmlcov/index.html
Expand Down Expand Up @@ -88,6 +114,9 @@ release: check-bump clean
git push upstream && git push upstream --tags
twine upload dist/*

pr: clean fix lint typecheck test
@echo "PR preparation complete! All checks passed."

# helpers

# verify that newsfragments are valid and towncrier can build them
Expand Down
49 changes: 47 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ py-multiaddr
.. image:: https://img.shields.io/pypi/v/multiaddr.svg
:target: https://pypi.python.org/pypi/multiaddr

.. image:: https://api.travis-ci.com/multiformats/py-multiaddr.svg?branch=master
:target: https://travis-ci.com/multiformats/py-multiaddr
.. image:: https://github.com/multiformats/py-multiaddr/actions/workflows/ci.yml/badge.svg
:target: https://github.com/multiformats/py-multiaddr/actions

.. image:: https://codecov.io/github/multiformats/py-multiaddr/coverage.svg?branch=master
:target: https://codecov.io/github/multiformats/py-multiaddr?branch=master
Expand All @@ -24,6 +24,19 @@ py-multiaddr

.. contents:: :local:

Installation
============

.. code-block:: bash

pip install multiaddr

Requirements
------------

- Python 3.10+
- trio (for async DNS resolution)

Usage
=====

Expand Down Expand Up @@ -217,11 +230,23 @@ Multiaddr provides thin waist address validation functionality to process multia

For comprehensive examples including error handling, practical usage scenarios, and detailed network interface information, see the `thin waist examples <https://github.com/multiformats/py-multiaddr/tree/master/examples/thin_waist>`_ in the examples directory.

Features
========

- **Multiaddr Protocol Support**: Full support for the multiaddr specification
- **DNS Resolution**: Async DNS and DNSADDR resolution with trio
- **Thin Waist Validation**: Network interface discovery and wildcard expansion
- **Protocol Support**: IPv4, IPv6, TCP, UDP, DNS, DNS4, DNS6, DNSADDR, p2p, p2p-circuit, onion, onion3, quic, tls, and more
- **Type Safety**: Full type hints and mypy support
- **Modern Python**: Python 3.10+ support with modern tooling

Maintainers
===========

Original author: `@sbuss`_.

Current maintainers: `@acul71`_, `@pacrob`_, `@manusheel`_.

Contribute
==========

Expand All @@ -230,6 +255,23 @@ Contributions welcome. Please check out `the issues`_.
Check out our `contributing document`_ for more information on how we work, and about contributing in general.
Please be aware that all interactions related to multiformats are subject to the IPFS `Code of Conduct`_.

Development
-----------

For development setup, see :doc:`contributing`.

.. code-block:: bash

# Clone the repository
git clone https://github.com/multiformats/py-multiaddr.git
cd py-multiaddr

# Install in development mode
pip install -e ".[dev]"

# Run the development workflow
make pr

License
=======

Expand All @@ -245,3 +287,6 @@ Dual-licensed:
.. _MIT: LICENSE-MIT
.. _Apache 2: LICENSE-APACHE2
.. _`@sbuss`: https://github.com/sbuss
.. _`@acul71`: https://github.com/acul71
.. _`@pacrob`: https://github.com/pacrob
.. _`@manusheel`: https://github.com/manusheel
3 changes: 3 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Contributing
============

.. include:: ../CONTRIBUTING.rst
2 changes: 1 addition & 1 deletion multiaddr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = "Steven Buss"
__email__ = "[email protected]"
__version__ = "0.0.9"
__version__ = "0.0.10"
Loading
Loading