Remove Python 2 compatibility and add mypy type checking - #433
Draft
richardkiss with Copilot wants to merge 11 commits into
Draft
Remove Python 2 compatibility and add mypy type checking#433richardkiss with Copilot wants to merge 11 commits into
richardkiss with Copilot wants to merge 11 commits into
Conversation
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
…notations Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
…v.txt Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
… in MANIFEST.in Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
… types, fix hash_f annotation Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
…ting Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
… 3.8 Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Co-authored-by: richardkiss <5336+richardkiss@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove Python 2 compatibility and add mypy type checking
Remove Python 2 compatibility and add mypy type checking
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drops Python 2 support, sets minimum version to Python 3.8, and introduces gradual type checking with mypy.
Compatibility Removal
intbytes.py,encoding/bytes32.py,ecdsa/intstream.py,ecdsa/rfc6979.pythat provided Python 2 fallbacks forint.to_bytes(),int.from_bytes(), andint.bit_length()from __future__ import print_functionfrom cmds modules; replaced urllib2/urllib compatibility layer with direct Python 3 importsraise NotImplemented()toraise NotImplementedError()in base classes (TxIn, TxOut, Tx, SolutionChecker)Type Annotations
Added type hints to core utility modules with Literal types for strict parameter validation:
Annotated modules:
intbytes,encoding/bytes32,encoding/hexbytes,ecdsa/intstream,ecdsa/rfc6979,merkle,bloomfilterConfiguration
python_requires='>=3.8', classifiers for Python 3.8-3.13python_version=3.8,ignore_missing_imports=True,disallow_untyped_defs=False)py.typedmarker for PEP 561 complianceDevelopment
Created
requirements-dev.txtwith pytest, coverage, mypy dependencies.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
blockchain.info/usr/bin/python python -m pytest tests/ -q(dns block)/usr/bin/python python -m pytest tests/ -q --tb=no --global k/_temp/copilot-developer-action-main/dist/ripgrep/bin/linux-x64/rg user.name(dns block)/usr/bin/python python -m pytest tests/ -q --tb=no origin de/node/bin/git(dns block)blockexplorer.com/usr/bin/python python -m pytest tests/ -q(dns block)/usr/bin/python python -m pytest tests/ -q --tb=no --global k/_temp/copilot-developer-action-main/dist/ripgrep/bin/linux-x64/rg user.name(dns block)/usr/bin/python python -m pytest tests/ -q --tb=no origin de/node/bin/git(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Summary
Remove all Python 2 compatibility code from the repository richardkiss/pycoin (branch: main) and add mypy static type checking to the codebase and CI. The PR should keep runtime behavior unchanged for Python 3.x users; it should simply stop maintaining Python 2 compatibility shims and add gradual type annotations and a mypy config and CI job. The changes should be small, reversible, and well-documented in the PR description.
Goals
Remove Python 2 compatibility vestiges across the codebase (no behavioral changes for Python 3):
Add mypy to the project and progressively annotate the code.
Add CI job and developer tooling to run mypy.
Run quick automated code modernizations where safe.
Testing and validation
Scope and Files to Change
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.