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
24 changes: 11 additions & 13 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"name": "UV: Python 3.13",
"name": "UV: Python 3.14",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "ghcr.io/astral-sh/uv:python3.13-bookworm",

"image": "ghcr.io/astral-sh/uv:python3.14-trixie",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {},

"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"username": "vscode"
}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
Expand All @@ -15,19 +17,15 @@
"balmacefa.linehighlightbookmarkvscode",
"charliermarsh.ruff",
"ms-python.debugpy",
"ms-python.mypy-type-checker",
"ms-python.python",
"ms-python.vscode-pylance",
"wayou.vscode-todo-highlight",
"elagil.pre-commit-helper",
"tamasfe.even-better-toml",
"mhutchie.git-graph"
"mhutchie.git-graph",
"meta.pyrefly",
"ms-python.vscode-python-envs"
]
}
},

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "uv sync",
// Run a non-root user
"remoteUser": "vscode"
"postCreateCommand": "uv sync --all-extras && source .venv/bin/activate"
}
84 changes: 58 additions & 26 deletions .github/workflows/pipelines.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,75 @@
name: pre-commit
name: CI Code Pipelines

on:
pull_request:
push:
branches: []
branches:
- main
- master

jobs:
BuildPackage:
lint:
name: Linting
runs-on: ubuntu-latest

steps:
# Setup
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

- name: Install UV
uses: astral-sh/setup-uv@v7
# Build Steps
- name: Build
run: uv build
- name: Upload Build Dist
uses: actions/upload-artifact@v4
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
with:
name: build_artifacts
path: dist/*
python-version: "3.13"

- name: Sync Dependencies
run: uv sync

- name: Pre-Commit
env:
SKIP: "pytest,uv-lock"
run: uv run pre-commit run --all-files

CodeLinting:
type-check:
name: Pyrefly
runs-on: ubuntu-latest

steps:
# Setup
- name: Checkout
uses: actions/checkout@v6
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

- name: Install UV
uses: astral-sh/setup-uv@v7
- name: Sync
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
with:
python-version: "3.13"

- name: Sync Dependencies
run: uv sync
# Linting Steps
- name: Pre-Commit
env:
# Found these unreliable in CI 17/1/25
SKIP: "mypy, pytest, uv-lock"
run: uv run pre-commit run --all-files
- name: MyPy
run: uv run mypy .

- name: Type Checking
run: uv run pyrefly check

- name: Type Coverage
run: uv run pyrefly coverage check --fail-under=90

test:
name: Tests
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

- name: Install UV
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
with:
python-version: "3.13"

- name: Sync Dependencies
run: uv sync

- name: Run Tests
run: |
uv run pytest \
--cov \
--cov-report=term-missing \
--cov-report=xml
67 changes: 18 additions & 49 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,65 +1,34 @@
name: publish
name: Publish

on:
push:
tags: [\d+\.\d+\.\d+]
tags:
- 'v*'
- '*.*.*'

jobs:
BuildPackage:
publish:
name: Build and Publish
runs-on: ubuntu-latest
steps:
# Setup
- name: Checkout
uses: actions/checkout@v6
- name: Install UV
uses: astral-sh/setup-uv@v7
# Build Steps
- name: Build
run: uv build
- name: Upload Build Dist
uses: actions/upload-artifact@v4
with:
name: build_artifacts
path: dist/*

CodeLinting:
runs-on: ubuntu-latest
steps:
# Setup
- name: Checkout
uses: actions/checkout@v6
- name: Install UV
uses: astral-sh/setup-uv@v7
- name: Sync
run: uv sync
# Linting Steps
- name: Pre-Commit
env:
# Found these unreliable in CI 17/1/25
SKIP: "mypy, pytest, uv-lock"
run: uv run pre-commit run --all-files
- name: MyPy
run: uv run mypy .

PublishPackage:
runs-on: ubuntu-latest
environment:
name: pypi

permissions:
id-token: write
contents: read
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- BuildPackage
- CodeLinting

steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Install Python 3.13
run: uv python install 3.13
- name: Build
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1

- name: Install UV
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
with:
python-version: "3.13"

- name: Build Package
run: uv build
- name: Publish

- name: Publish Package
run: uv publish
51 changes: 27 additions & 24 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ repos:
- id: check-docstring-first

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.1
rev: v0.16.9
hooks:
# Run the linter.
- id: ruff-check
Expand All @@ -44,39 +44,42 @@ repos:
# Run the formatter.
- id: ruff-format

- repo: local
- repo: https://github.com/facebook/pyrefly-pre-commit
rev: 1.4.0.dev1
hooks:
- id: mypy
name: mypy
- id: pyrefly-check
name: pyrefly
stages:
- pre-commit
- pre-push
language: system
entry: uv run mypy
language: system # Use system-installed pyrefly
files: .*(\.py|\.pyi)$
args: [src]
# Recommended to do full repo checks.
# However, you can change this to `true` to only check changed files
pass_filenames: false

# - repo: local
# hooks:
# - id: pytest
# name: pytest
# stages:
# - pre-commit
# - pre-push
# language: system
# entry: uv run pytest
# files: (src|tests)/.*(\.py|\.pyi)$
# args:
# - tests
# - -q
# - --no-summary
# - --no-header
# pass_filenames: false
- repo: local
hooks:
- id: pytest
name: pytest
stages:
- pre-commit
- pre-push
language: system
entry: uv run pytest
files: (src|tests)/.*(\.py|\.pyi)$
args:
- tests
- -q
- --no-summary
- --no-header
# Recommended to do full repo checks.
# However, you can change this to `true` to only check changed files
pass_filenames: false

- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.12.1
rev: 0.12.18
hooks:
# Ensure the lockfile is up-to-date
- id: uv-lock
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.13
>=3.13
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,7 @@ IPV4_HEADER = Struct(
"flags" / Struct(Padding(1), "dont_fragment" / Flag(), "more_fragments" / Flag()),
"fragment_offset" / Bits(13),
"ttl" / Bits(8),
"protocol"
/ Enum(
8,
ICMP=1,
TCP=6,
UDP=17,
),
"protocol" / Enum(8, ICMP=1, TCP=6, UDP=17),
"checksum" / Bits(16),
"source_ip" / IpAddress(Bits(32)),
"destination_ip" / IpAddress(Bits(32)),
Expand All @@ -855,12 +849,7 @@ TCP_HEADER = Struct(
"destination_port" / Bits(16),
"seq" / Bits(32),
"ack" / Bits(32),
"length"
/ ExprAdapter(
Bits(4),
encoder=lambda obj: obj * 4,
decoder=lambda obj: ceil(obj / 4),
),
"length" / ExprAdapter(Bits(4), encoder=lambda obj: obj * 4, decoder=lambda obj: ceil(obj / 4)),
Padding(3),
"flags"
/ Struct(
Expand Down
Loading
Loading