Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
30b346f
fix pyproject.toml , add ruff
arcinston May 19, 2025
5d7b8a4
rm lock
arcinston May 19, 2025
53a41ea
make progress
arcinston May 19, 2025
62beed4
add poetry lock ignore
arcinston May 19, 2025
83a4932
fix type issues
arcinston May 21, 2025
ebe53fa
fix tcp type errors
arcinston May 21, 2025
d46c137
fix text example - type error - wrong args
arcinston May 21, 2025
c2e96a0
merge upsstream to fork
arcinston May 21, 2025
b050807
add setuptools to dev
arcinston May 21, 2025
b452081
test ci
arcinston May 21, 2025
2cc9c60
fix docs build
arcinston May 21, 2025
8795663
fix type issues for new_swarm & new_host
arcinston May 22, 2025
7e95e69
fix types in gossipsub
arcinston May 22, 2025
239d51b
fix type issues in noise
arcinston May 22, 2025
f4fec67
wip: factories
arcinston May 22, 2025
a297826
revert factories
arcinston May 22, 2025
747a658
fix more type issues
arcinston May 23, 2025
57650f6
merge main
arcinston May 23, 2025
1a334f3
more type fixes
arcinston May 23, 2025
b072af4
fix: add null checks for noise protocol initialization and key handling
acul71 May 25, 2025
8cb2211
corrected argument-errors in peerId and Multiaddr in peer tests
kaneki003 May 25, 2025
c2b570b
Merge pull request #3 from kaneki003/wip/lint-typecheck-revamp
arcinston May 25, 2025
143d455
fix: Noice - remove redundant type casts in BaseNoiseMsgReadWriter
acul71 May 25, 2025
da8251f
fix: update test_notify.py to use SwarmFactory.create_batch_and_liste…
acul71 May 25, 2025
5de49a8
Fix type checks for pubsub module
sukhman-sukh May 25, 2025
a9e6328
Fix type checks for pubsub module-tests
sukhman-sukh May 25, 2025
0f9392c
noise: add checks for uninitialized protocol and key states in PatternXX
varun-r-mallya May 26, 2025
1df86d1
pubsub: add None checks for optional fields in FloodSub and Pubsub
varun-r-mallya May 26, 2025
ffa8a7b
Fix type hints and improve testing
varun-r-mallya May 26, 2025
e61b873
Merge pull request #2 from acul71/wip/issue-618-lint-typecheck-revamp
arcinston May 26, 2025
0af7ea6
Merge pull request #4 from sukhman-sukh/fix-type-check/pubsub
arcinston May 26, 2025
13d3b1c
Merge pull request #5 from sukhman-sukh/fix-type-check/test-pubsub
arcinston May 26, 2025
fb068cb
Merge branch 'main' into typing
varun-r-mallya May 26, 2025
ad555d9
remove redundant checks
varun-r-mallya May 26, 2025
1b21703
fix build issues
arcinston May 26, 2025
8bbb126
add optional to trio service
arcinston May 26, 2025
4dc5b95
merge main
arcinston May 26, 2025
0ca9948
fix types
arcinston May 26, 2025
de0cc33
Merge branch 'main' into typing
varun-r-mallya May 26, 2025
4b4a187
fix type errors
arcinston May 26, 2025
2090dab
Merge pull request #7 from varun-r-mallya/typing
arcinston May 26, 2025
5430eb5
Fix type errors
varun-r-mallya May 26, 2025
99ecc79
fixed more-type checks in crypto and peer_data files
kaneki003 May 27, 2025
f269e44
wip: factories
arcinston May 27, 2025
02629c7
Merge pull request #9 from varun-r-mallya/typing
arcinston May 27, 2025
2272c42
Merge branch 'main' into wip/lint-typecheck-revamp
kaneki003 May 27, 2025
a26e99b
replaced union with optional
kaneki003 May 27, 2025
10d99d6
Merge pull request #10 from kaneki003/wip/lint-typecheck-revamp
arcinston May 27, 2025
d1a9537
fix: type-error in interp-utils and peerinfo
lla-dane May 30, 2025
7283948
Merge pull request #11 from lla-dane/type-fix
arcinston May 31, 2025
5559c40
replace pyright with pyrefly
arcinston Jun 1, 2025
6513783
add pyrefly.toml
arcinston Jun 1, 2025
f0cb70b
Merge remote-tracking branch 'upstream/main'
arcinston Jun 1, 2025
780f958
wip: fix multiselect issues
arcinston Jun 1, 2025
34c0e2a
try typecheck
arcinston Jun 2, 2025
318fab3
base check
arcinston Jun 2, 2025
082a4e0
mcache test fixes , typecheck ci update
arcinston Jun 2, 2025
8eb2ed2
fix ci
arcinston Jun 2, 2025
08ed976
will this work
arcinston Jun 2, 2025
73c38e4
minor fix
arcinston Jun 2, 2025
1c5827b
use poetry
arcinston Jun 2, 2025
f745426
fix wokflow
arcinston Jun 2, 2025
2de7ff0
use cache,fix err
arcinston Jun 2, 2025
5850026
fix pyrefly.toml
arcinston Jun 2, 2025
f84ea35
fix pyrefly.toml
arcinston Jun 2, 2025
99c8cf7
Merge pull request #12 from arcinston/dev
arcinston Jun 2, 2025
0eaa8e4
fix cache in ci
arcinston Jun 2, 2025
3e61704
deploy commit
arcinston Jun 2, 2025
3df4434
add main baseline
arcinston Jun 2, 2025
5f99c8f
update to v5
arcinston Jun 2, 2025
93cc002
Merge pull request #13 from arcinston/dev
arcinston Jun 2, 2025
8229051
improve typecheck ci (#14)
arcinston Jun 2, 2025
c16a66e
fix typo
arcinston Jun 2, 2025
5b99373
remove holepunching code (#16)
arcinston Jun 2, 2025
588753a
fix gossipsub typeerrors (#17)
arcinston Jun 2, 2025
ada819f
fix: ensure initiator user includes remote peer id in handshake (#15)
0-th Jun 2, 2025
e3ffebd
fix ci (#19)
arcinston Jun 2, 2025
13236cc
typefix: custom_types | core/peerinfo/test_peer_info | io/abc | pubsu…
lla-dane Jun 2, 2025
d50818c
fix: Typefixes in PeerInfo (#21)
lla-dane Jun 5, 2025
55c50aa
fix minor type issue (#22)
arcinston Jun 5, 2025
d033d6c
fix type errors in pubsub (#24)
guha-rahul Jun 5, 2025
c9d0385
fix: Minor typefixes in tests (#23)
lla-dane Jun 5, 2025
4b2acba
Fix failing tests for type-fixed test/pubsub (#8)
sukhman-sukh Jun 7, 2025
b456a11
move pyrefly & ruff to pyproject.toml & rm .project-template (#28)
arcinston Jun 7, 2025
d1b6568
move the async_context file to tests/core
arcinston Jun 7, 2025
a5b9818
move crypto test to crypto folder
arcinston Jun 7, 2025
06465e1
fix: some typefixes (#25)
guha-rahul Jun 8, 2025
7185377
fix type errors
arcinston Jun 8, 2025
0321e02
fix type issues
arcinston Jun 8, 2025
743dfa6
fix: update gRPC API usage in autonat_pb2_grpc.py (#31)
acul71 Jun 9, 2025
7876dd6
merge main , fix type erros
arcinston Jun 9, 2025
b6c13c1
Fix: Address remaining type errors in security tests
Aldorax Jun 9, 2025
db28161
Fix(tests): Resolve Muxed Connection Type Assertion Error
Aldorax Jun 9, 2025
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
182 changes: 182 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Typecheck

on:
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
typecheck_pr:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry

- name: Configure Poetry
run: |
poetry config virtualenvs.in-project true
poetry config virtualenvs.create true

- name: Get Poetry version
id: poetry-version
run: echo "version=$(poetry --version | awk '{print $3}')" >> $GITHUB_OUTPUT

- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: poetry-cache
with:
path: |
.venv
~/.cache/pypoetry/virtualenvs
~/.cache/pypoetry/cache
key: ${{ runner.os }}-poetry-${{ steps.poetry-version.outputs.version }}-python-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-poetry-${{ steps.poetry-version.outputs.version }}-python-
${{ runner.os }}-poetry-

- name: Install dependencies with Poetry
run: poetry install --all-extras --no-interaction

- name: Run typecheck on PR and generate current errors
id: run_pr_typecheck
run: |
set -eo pipefail
poetry run make typecheck 2>&1 | tee pr_typecheck.log || true
grep '^ERROR ' pr_typecheck.log > pr_errors.txt || touch pr_errors.txt
echo "PR typecheck log generated: pr_errors.txt"
echo "pr_errors_path=pr_errors.txt" >> $GITHUB_OUTPUT

- name: Download main error baseline artifact
id: download_main_baseline
uses: dawidd6/action-download-artifact@v3
with:
workflow: update-main-baseline.yml
name: main-type-errors-baseline
path: downloaded_baseline
if_no_artifact_found: warn
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare baseline errors file for PR comparison
id: prepare_pr_baseline
run: |
if [ -f downloaded_baseline/main_errors.txt ]; then
cp downloaded_baseline/main_errors.txt actual_baseline_errors.txt
echo "Baseline 'actual_baseline_errors.txt' prepared from downloaded main artifact."
else
echo "::warning title=Main Baseline Not Found::Artifact 'main-type-errors-baseline' from 'update-main-baseline.yml' (main branch) not found or download failed. Proceeding with an empty baseline. All current errors will be treated as new."
touch actual_baseline_errors.txt
fi
echo "pr_baseline_path=actual_baseline_errors.txt" >> $GITHUB_OUTPUT

- name: Upload PR typecheck log and current errors (for debugging)
if: always()
uses: actions/upload-artifact@v4
with:
name: pr-typecheck-output
path: |
pr_typecheck.log
pr_errors.txt
downloaded_baseline/
actual_baseline_errors.txt

- name: Compare PR errors with main, comment & fail on new
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
const pr_number = context.payload.pull_request.number;

const current_errors_file = process.env.INPUT_CURRENT_ERRORS_PATH;
const baseline_errors_file = process.env.INPUT_BASELINE_ERRORS_PATH;

let current_errors_content = "";
if (fs.existsSync(current_errors_file)) {
current_errors_content = fs.readFileSync(current_errors_file, 'utf8');
} else {
core.warning(`Current PR errors file '${current_errors_file}' not found.`);
}
const current = current_errors_content.trim().split('\n').filter(Boolean);

let baseline_errors_content = "";
if (fs.existsSync(baseline_errors_file)) {
baseline_errors_content = fs.readFileSync(baseline_errors_file, 'utf8');
} else {
core.warning(`Prepared baseline errors file '${baseline_errors_file}' not found. Assuming empty baseline.`);
}
const previous = baseline_errors_content.trim().split('\n').filter(Boolean);

const added = current.filter(e => !previous.includes(e));
const removed = previous.filter(e => !current.includes(e));

const comment_lines = [
"**Typecheck Report (Comparison with `main` Branch Baseline)**",
`* Total errors in this PR: **${current.length}**`,
`* Total errors in \`main\` branch baseline: **${previous.length}**`
];

if (removed.length > 0) {
comment_lines.push(`\n🎉 **Fixed ${removed.length} error(s) that were in the \`main\` baseline:**`);
comment_lines.push("```diff");
removed.forEach(e => comment_lines.push(`- ${e}`));
comment_lines.push("```");
}

if (added.length > 0) {
comment_lines.push(`\n🚨 **Introduced ${added.length} new error(s) not present in the \`main\` baseline:**`);
comment_lines.push("```diff");
added.forEach(e => comment_lines.push(`+ ${e}`));
comment_lines.push("```");
}

if (added.length === 0 && removed.length === 0 ) {
if (current.length === 0) {
comment_lines.push(`\n✅ No type errors in this PR and \`main\` baseline is also clean (or matches)!`);
} else if (current.length === previous.length) {
comment_lines.push(`\nNo change in type errors. This PR has **${current.length}** error(s), consistent with the \`main\` baseline.`);
}
}

comment_lines.push("\n<details><summary>Full list of errors in this PR</summary>");
comment_lines.push("\n```txt");
if (current.length > 0) {
current.forEach(e => comment_lines.push(e));
} else {
comment_lines.push("(No errors found in this PR)");
}
comment_lines.push("```");
comment_lines.push("</details>");

try {
await github.rest.issues.createComment({
owner,
repo,
issue_number: pr_number,
body: comment_lines.join("\n")
});
} catch (error) {
core.error(`Failed to create PR comment: ${error.message}. Ensure the GITHUB_TOKEN has 'issues: write' permissions.`);
}

if (added.length > 0) {
core.setFailed(`New type errors introduced relative to main: ${added.length}. See PR comment for details.`);
}
env:
INPUT_CURRENT_ERRORS_PATH: ${{ steps.run_pr_typecheck.outputs.pr_errors_path }}
INPUT_BASELINE_ERRORS_PATH: ${{ steps.prepare_pr_baseline.outputs.pr_baseline_path }}
70 changes: 70 additions & 0 deletions .github/workflows/update-main-baseline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Update Main Typecheck Baseline

on:
push:
branches:
- main

jobs:
generate_baseline:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Install Poetry
run: |
python -m pip install --upgrade pip
pip install poetry

- name: Configure Poetry
run: |
poetry config virtualenvs.in-project true
poetry config virtualenvs.create true

- name: Get Poetry version
id: poetry-version
run: echo "version=$(poetry --version | awk '{print $3}')" >> $GITHUB_OUTPUT

- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: poetry-cache
with:
path: |
.venv
~/.cache/pypoetry/virtualenvs
~/.cache/pypoetry/cache
key: ${{ runner.os }}-poetry-${{ steps.poetry-version.outputs.version }}-python-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-poetry-${{ steps.poetry-version.outputs.version }}-python-
${{ runner.os }}-poetry-

- name: Install dependencies with Poetry
run: poetry install --all-extras --no-interaction

- name: Run typecheck and generate baseline errors for main
id: generate_main_errors
run: |
set -eo pipefail
# Run typecheck, tee output to log, allow command to proceed even if typecheck finds errors
poetry run make typecheck 2>&1 | tee main_typecheck.log || true
# Extract errors, or create an empty file if no errors
grep '^ERROR ' main_typecheck.log > main_errors.txt || touch main_errors.txt
echo "Baseline 'main_errors.txt' generated for main branch."
# Optional: Check if main has errors and warn/error
if [ -s main_errors.txt ]; then
echo "::warning title=Type Errors on Main::Type errors found on main branch. These will form the baseline. Check 'main_errors.txt' in the artifact."
fi
echo "baseline_file_path=main_errors.txt" >> $GITHUB_OUTPUT

- name: Upload main error baseline artifact
uses: actions/upload-artifact@v4
with:
name: main-type-errors-baseline
path: ${{ steps.generate_main_errors.outputs.baseline_file_path }}
retention-days: 90
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ instance/
# PyBuilder
target/

# PyRight Config
pyrightconfig.json

# Jupyter Notebook
.ipynb_checkpoints

Expand All @@ -171,3 +174,7 @@ env.bak/

# mkdocs documentation
/site

#lockfiles
uv.lock
poetry.lock
68 changes: 29 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,59 +1,49 @@
exclude: '.project-template|docs/conf.py|.*pb2\..*'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
- id: check-yaml
- id: check-toml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/psf/black
rev: 23.9.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.10
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.9.16
exclude: setup.py
- repo: https://github.com/PyCQA/autoflake
rev: v2.2.1
hooks:
- id: autoflake
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies:
- tomli # required until >= python311
- repo: https://github.com/executablebooks/mdformat
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.22
hooks:
- id: mdformat
- id: mdformat
additional_dependencies:
- mdformat-gfm
- repo: local
- mdformat-gfm
- repo: local
hooks:
- id: mypy-local
- id: mypy-local
name: run mypy with all dev dependencies present
entry: python -m mypy -p libp2p
entry: mypy -p libp2p
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
- repo: local

- repo: local
hooks:
- id: check-rst-files
- id: check-rst-files
name: Check for .rst files in the top-level directory
entry: python -c "import glob, sys; rst_files = glob.glob('*.rst'); sys.exit(1) if rst_files else sys.exit(0)"
language: system
Expand Down
Loading