Skip to content

Conversation

@acul71
Copy link
Contributor

@acul71 acul71 commented Sep 9, 2025

Pull Request #90: Development Infrastructure Improvements and py-cid Dependency Update

Overview

This pull request introduces significant improvements to the development infrastructure, type safety, and dependency management for the py-multiaddr project. The changes align the project with py-libp2p development standards and ensure better code quality through enhanced type checking and automated workflows.

Summary of Changes

🔧 Development Infrastructure & Workflow Improvements

1. py-libp2p-style Typecheck Functionality and PR Workflow (66fae37)

  • Added comprehensive Makefile targets:
    • make help - Display available targets
    • make pr - Complete PR workflow (clean → fix → lint → typecheck → test)
    • make fix - Auto-fix code issues
    • make typecheck - Run type checking with mypy and pyrefly
  • Enhanced pre-commit configuration:
    • Added local typecheck hooks
    • Updated setup target to use pyproject.toml dev dependencies
  • Updated dependencies:
    • Added mypy and pyrefly to dev dependencies
    • Added type stubs for netaddr and psutil
  • Workflow alignment: Matches py-libp2p workflow pattern

2. Coverage and Authors Management (661fc64)

  • Fixed coverage target: Updated to use pytest instead of deprecated setup.py test
  • Updated AUTHORS file: Added latest contributors from git history (25 new contributors)

🎯 Type Safety Improvements

3. Comprehensive MyPy Type Annotation Fixes (df2903a)

  • Codec improvements:
    • Added missing type annotations to all codec methods (to_bytes, to_string)
    • Fixed type annotations across 9 codec modules (cid, domain, fspath, ip4, ip6, onion, onion3, uint16be, utf8)
  • Exception handling:
    • Added return type annotations to __str__ methods in exceptions
    • Fixed bytes formatting issue in BinaryParseError.__str__
  • DNS resolver enhancements:
    • Added proper type annotations to DNS resolver methods
    • Fixed dict type parameters in resolver options
    • Added type annotation to DNSResolver instance in multiaddr.py
  • Code quality:
    • Broke long function signatures to comply with line length limits
    • All changes verified with mypy, tests, and make pr

📦 Release Management

4. Release Notes Compilation for v0.0.10 (9242362)

  • Generated comprehensive release notes from newsfragments
  • Cleaned up newsfragments after compilation:
    • Removed 10 processed newsfragments (65.feature, 65.internal, 66.feature, 68.feature, 72.feature, 74.feature, 75.docs, 80.feature, 80.internal, 85.internal)
  • Updated HISTORY.rst with 28 new lines of release information

🔄 Dependency Management

5. py-cid Dependency Updates (1191997, eb14eb3)

  • Updated py-cid dependency to use specific git commit: 807b8ba541d4367d92ac541e198e4b67e101ec2e
  • Merged latest master changes including:
    • Master's py-cid updates to commit 6c5d62f865e380116689d11348a4be82fe4f2703
  • Resolved merge conflicts by commenting out master's py-cid and maintaining the specific commit requirement
  • Maintained backward compatibility while ensuring consistent dependency management

Technical Details

Files Modified

  • Configuration files: .pre-commit-config.yaml, Makefile, pyproject.toml
  • Source code: 15 files across codecs, resolvers, exceptions, and core modules
  • Documentation: AUTHORS, HISTORY.rst
  • Release management: 10 newsfragments processed and cleaned

Dependencies Added

  • mypy - Static type checking
  • pyrefly - Additional type checking
  • types-netaddr - Type stubs for netaddr
  • types-psutil - Type stubs for psutil

Quality Assurance

  • All changes verified with make pr workflow
  • Type checking passes with mypy and pyrefly
  • Tests continue to pass
  • Pre-commit hooks updated and functional

Benefits

  1. Enhanced Developer Experience:

    • Streamlined development workflow with make pr
    • Automated code quality checks
    • Clear help system with make help
  2. Improved Code Quality:

    • Comprehensive type annotations
    • Better error handling and debugging
    • Consistent code formatting
  3. Better Maintainability:

    • Aligned with py-libp2p standards
    • Automated release note generation
    • Updated contributor recognition
  4. Dependency Management:

    • Specific commit pinning for stability
    • Successful merge with latest master changes
    • Maintained compatibility

Testing

  • ✅ All existing tests pass
  • ✅ Type checking passes with mypy
  • ✅ Pre-commit hooks functional
  • make pr workflow completes successfully
  • ✅ Coverage reporting updated and functional

Breaking Changes

None. All changes are backward compatible and maintain existing API contracts.

Migration Notes

Developers can now use the new make pr command for a complete development workflow. The enhanced type checking will help catch potential issues early in development.


Author: acul71
Branch: new_install
Commits: 6
Files Changed: 20+
Status: Ready for review

acul71 added 6 commits August 28, 2025 14:08
- Add make help and make pr targets
- Add make fix and make typecheck targets
- Add mypy and pyrefly to dev dependencies
- Add type stubs for netaddr and psutil
- Update pre-commit config with local typecheck hooks
- Update setup target to use pyproject.toml dev dependencies
- Match py-libp2p workflow: clean → fix → lint → typecheck → test
- Add missing type annotations to all codec methods (to_bytes, to_string)
- Add return type annotations to __str__ methods in exceptions
- Fix bytes formatting issue in BinaryParseError.__str__
- Add proper type annotations to DNS resolver methods
- Fix dict type parameters in resolver options
- Add type annotation to DNSResolver instance in multiaddr.py
- Break long function signature to comply with line length limits
- All changes verified with mypy, tests, and make pr
- Fix coverage target to use pytest instead of setup.py test
- Update AUTHORS file with latest contributors from git history
@acul71
Copy link
Contributor Author

acul71 commented Sep 9, 2025

@pacrob @seetadev
This is ready for review. Please check also documentation, licenses, etc.

In pyproject.toml I'm using temporary github py-cid with last commit of acul71/new-setup branch

"py-cid @ git+https://github.com/ipld/py-cid@807b8ba541d4367d92ac541e198e4b67e101ec2e",

This will need to be changed in

"py-cid",

when the py-cid package will be published in PyPi

@seetadev
Copy link
Contributor

@pacrob : Hi Paul. This looks ready for final review + merge. Will wait for your thumbs up before merging the PR. Looking forward to your feedback.

Thank you @acul71 for your wonderful contribution. Appreciate your efforts.

…ded v0.0.9 notes, updated .gitignore for HTML files, and documented all typing updates and recent commits - project ready for release.
@acul71
Copy link
Contributor Author

acul71 commented Sep 13, 2025

@pacrob @seetadev
Doc issues fixed: Try now.

@seetadev
Copy link
Contributor

@acul71 : Great, thank you so much Luca for addressing Paul's feedback. Appreciate it.

This is indeed looking better. Reviewing it in detail. Thank you so much for fixing the doc issues.

@pacrob will be reviewing py-multiaddr PR's today as we had a py-cid release yesterday. Thank you so much @pacrob for your great support and pointers.

@acul71
Copy link
Contributor Author

acul71 commented Sep 13, 2025

@pacrob @seetadev
I've seen that windows is not covered in CI/CD.
Should I add it ?
Is this the file? : .github/workflows/tox.yml

@seetadev
Copy link
Contributor

@acul71 : Yes, that is exactly what was not covered in py-cid earlier. Please do include windows in CI/CD at .github/workflows/tox.yml

Great find indeed, Luca. Appreciate your efforts.

@acul71
Copy link
Contributor Author

acul71 commented Sep 13, 2025

@seetadev
why are windows ci/cd tests so slow compared to linux ?

@acul71
Copy link
Contributor Author

acul71 commented Sep 13, 2025

@acul71 : Yes, that is exactly what was not covered in py-cid earlier. Please do include windows in CI/CD at .github/workflows/tox.yml

Great find indeed, Luca. Appreciate your efforts.

Done
PS: why we don't test python 3.10 in windows in py-libp2p and py-cid ?

@pacrob
Copy link
Contributor

pacrob commented Sep 13, 2025

Done PS: why we don't test python 3.10 in windows in py-libp2p and py-cid ?

I think that's just an artifact from when py-libp2p was on the same template as other ethereum libraries. We only added windows tests starting when py311 was released, just never went back and added earlier.

@pacrob pacrob merged commit b186e2c into master Sep 13, 2025
17 checks passed
@pacrob pacrob deleted the new_install branch September 13, 2025 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants