Skip to main content

PyConflict

CI codecov License: MIT Code style: black

Python Dependency Conflict Checker - Check before you install

PyConflict checks Python package dependency constraints before installation. It supports PEP 508 environment markers, installed-environment audits, batch checks, and integrations for AI coding tools.

It answers one question: "Will adding this package conflict with versions already installed?"

Unlike existing tools that detect conflicts after installation, PyConflict is proactive - it checks dependencies before making changes.

Why PyConflict?

The Problem:

# requirements.txt pins django==3.2 and asgiref==3.2.0
$ python -m pip install -r requirements.txt
ERROR: django==3.2 requires asgiref>=3.3.2,<4, but asgiref==3.2.0 is pinned

The Solution:

$ pyconflict check-add django==3.2
✗ Cannot add django==3.2

  Conflicts detected:
    • asgiref
      Required: <4,>=3.3.2
      Installed: 3.2.0

  Suggestions:
    → Upgrade 'asgiref' from 3.2.0 to satisfy django's requirement (<4,>=3.3.2)

Features

  • ✅ Proactive conflict detection - Check dependency constraints before installing
  • ✅ AI-assistant friendly - JSON output for Claude Code, Cursor, Copilot
  • ✅ Editor integrations - Cursor instructions, an MCP server, and a VS Code extension
  • ✅ PEP 508 markers - Ignore requirements that do not apply to the selected Python and platform
  • ✅ Cached PyPI metadata - Reuse package data between checks
  • ✅ Direct dependencies - Checks package's immediate dependencies against installed versions
  • ✅ Latest stable version - Find the newest non-prerelease version
  • ✅ Clean Architecture - Maintainable, testable, extensible codebase
  • ✅ Tests - Unit and integration test suites are included

Current limits

  • check-add checks direct dependencies. It does not resolve transitive dependencies.
  • Optional extras such as package[security] are not included.
  • batch-check accepts package names and exact == pins only.
  • Private package indexes are not supported.

Installation

From source (current)

git clone https://github.com/alimoradi296/PyConflict.git
cd PyConflict
python -m pip install .

PyConflict does not have a published PyPI release yet. The PyPI install command will be added here after a release is published.

Development install

python -m pip install -e ".[dev]"

Verify Installation

pyconflict --help

Quick Start

Check if a package is safe to add

# Check latest version
$ pyconflict check-add tensorflow

# Check specific version
$ pyconflict check-add django==3.2

# JSON output (for AI tools)
$ pyconflict check-add requests --json

Get latest stable version

# Latest version
$ pyconflict stable pandas

# Filter by Python version
$ pyconflict stable numpy --python-version 3.8

Check the installed environment and multiple package candidates

pyconflict check-env --json
pyconflict batch-check -p django -p "requests==2.31.0" --json

batch-check accepts package names or exact == pins. It rejects version ranges, extras, and environment markers.

Optional team baseline check

From the repository checkout, install Redis support with python -m pip install ".[team]", then configure PYCONFLICT_WORKSPACE_ID and PYCONFLICT_REDIS_URL. Compare the current environment with a saved baseline by running pyconflict team-check. To explicitly save the current package names and versions as the shared baseline, run pyconflict team-check --set-standard. Saving sends those names and versions to the configured Redis service; a normal check only reads the baseline.

Usage

Command: check-add

Check if adding a package will cause conflicts with your current environment.

pyconflict check-add <package> [OPTIONS]

Options:

  • --version TEXT - Specific version to check
  • --json - Output in JSON format

Exit codes:

  • 0 - Safe to add, no conflicts
  • 1 - Conflict detected
  • 2 - Package not found
  • 4 - Repository error
  • 5 - Unexpected error

Examples:

# Safe to add
$ pyconflict check-add fastapi
✓ Safe to add fastapi==0.104.1

# Conflict detected
$ pyconflict check-add django==3.2
✗ Cannot add django==3.2

Conflicts detected:
  • asgiref
    Required: <4,>=3.3.2
    Installed: 3.2.0

Suggestions:
  → Upgrade 'asgiref' from 3.2.0 to satisfy django's requirement (<4,>=3.3.2)

# JSON output
$ pyconflict check-add django==3.2 --json
{
  "status": "conflict",
  "exit_code": 1,
  "package": {
    "name": "django",
    "version": "3.2.0"
  },
  "conflicts": [
    {
      "dependency": "asgiref",
      "required": "<4,>=3.3.2",
      "installed": "3.2.0",
      "required_by": "django==3.2.0",
      "severity": "error"
    }
  ],
  "suggestions": [
    "Upgrade 'asgiref' from 3.2.0 to satisfy django's requirement (<4,>=3.3.2)"
  ],
  "caveats": [
    "Only direct dependencies checked (not transitive)",
    "Optional extras not included"
  ]
}

Command: stable

Get the latest stable (non-prerelease) version of a package.

pyconflict stable <package> [OPTIONS]

Options:

  • --python-version TEXT - Filter by Python version compatibility
  • --json - Output in JSON format

Examples:

$ pyconflict stable pandas
pandas==2.1.4

$ pyconflict stable numpy --python-version 3.8
numpy==1.24.4 (filtered by Python version)

AI Assistant Integration

For Claude Code

PyConflict is designed to be called by AI coding assistants:

# Claude internally runs:
result=$(pyconflict check-add tensorflow --json)
exit_code=$?

if [ $exit_code -eq 0 ]; then
    echo "tensorflow==2.15.0" >> requirements.txt
else
    # Show conflict to user
    echo "Cannot add tensorflow: conflicts detected"
fi

For Cursor

Add to .cursor/rules:

Before adding Python packages:
1. Run: pyconflict check-add <package> --json
2. Only proceed if exit_code == 0

Architecture

PyConflict follows Clean Architecture principles:

┌─────────────────────┐
│   CLI (Typer)       │  ← Presentation Layer
└──────────┬──────────┘
           │
┌──────────▼──────────┐
│   Use Cases         │  ← Application Layer
│ • CheckAddPackage   │
│ • GetLatestStable   │
└──────────┬──────────┘
           │
┌──────────▼──────────┐
│  Domain Services    │  ← Domain Layer
│ • ConflictDetector  │
│ • VersionResolver   │
└──────────┬──────────┘
           │
┌──────────▼──────────┐
│  Infrastructure     │  ← Infrastructure Layer
│ • PyPI Repository   │
│ • Disk Cache        │
│ • Pip Environment   │
└─────────────────────┘

Key benefits:

  • Testable: Domain logic has zero external dependencies
  • Swappable: Can replace PyPI with private registry without touching business logic
  • Maintainable: Clear boundaries prevent spaghetti code

Performance

PyConflict is designed for speed:

  • Cached requests: < 2 seconds
  • Uncached requests: < 10 seconds
  • Stable version lookup: < 5 seconds
  • Parallel requests: Supports concurrent package checks

The timings above are targets and have not been verified for this checkout.

Development

Setup

# Clone the repository
git clone https://github.com/alimoradi296/PyConflict.git
cd PyConflict

# Create virtual environment
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows

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

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=pyconflict --cov-report=html

# Run only unit tests (fast)
pytest tests/unit -v

# Run integration tests (requires network)
pytest tests/integration -v -m integration

# Run specific test
pytest tests/unit/domain/test_version_resolver.py

Code Quality

# Format code
black src tests

# Lint
ruff check src tests

# Type check
mypy src

# Run all checks (CI simulation)
black --check src tests && ruff check src tests && mypy src && pytest

Limitations

PyConflict checks direct dependencies for check-add and installed distribution requirements for check-env:

  • ⚠️ Direct dependencies only - Transitive dependencies are not checked
  • ⚠️ Extras not checked - package[security] extras are not included
  • ⚠️ Public PyPI only - Private registries are not supported
  • ⚠️ Suggestions only - No automatic fixes (by design - user decides)

Accuracy is not measured. The tool checks direct dependency constraints against the current environment. It does not resolve the full dependency graph.

PyConflict does not report a confidence percentage. Its checks cover documented inputs; they are not a guarantee that an installation will succeed.

See Roadmap for current priorities.

Roadmap

Current implementation

  • ✅ Direct dependency conflict detection
  • ✅ PEP 508 environment marker evaluation
  • ✅ Installed environment check
  • ✅ Batch package checks
  • ✅ Latest stable version lookup
  • ✅ CLI with JSON output
  • ✅ Redis-backed team baseline (explicit opt-in when saving)
  • ✅ MCP server and VS Code extension source package
  • ✅ Cursor setup instructions

Planned

  • Transitive dependency analysis with explicit graph and cycle handling
  • Extras handling (package[extra])
  • Real-service acceptance checks for MCP stdio, Redis, and the VS Code host
  • Private index support after credential and configuration behavior is designed

See ROADMAP.md for current project priorities.

FAQ

Q: How is this different from pip check? A: pip check is reactive - it checks for conflicts after installation. PyConflict is proactive - it checks before you install.

Q: Does it work with private PyPI repositories? A: No. PyConflict currently reads package metadata from public PyPI.

Q: Can it automatically fix conflicts? A: No. PyConflict provides suggestions, but you decide what to do. Automatic fixes are too risky.

Q: How accurate is it? A: We have not measured accuracy. check-add checks direct dependencies and evaluates their environment markers. It does not check transitive dependencies or optional extras.

Q: Does it replace poetry/pip-tools? A: No. PyConflict is a checker, not a package manager or lock file tool. Use it alongside your existing tools.

Contributing

Contributions are welcome! We need help with:

  • 🐛 Bug reports and fixes
  • ✨ Feature implementations
  • 📝 Documentation improvements
  • 🧪 Test coverage expansion
  • 🌍 Translations (future)

Please see CONTRIBUTING.md for guidelines.

Development Workflow

  1. Fork and clone the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Ensure all tests pass (pytest)
  5. Ensure code quality (black, ruff, mypy)
  6. Commit with conventional commits (feat:, fix:, etc.)
  7. Push and create a Pull Request

Community

  • 🐛 Report bugs or request features: GitHub Issues
  • 💬 Ask questions: Open a GitHub issue and describe what you are trying to do.
  • 🤝 Contribute: See CONTRIBUTING.md

License

MIT License - see LICENSE for details.

Star History

If PyConflict saves you time, please give it a star on GitHub!

Star History Chart

Credits

Built with:

  • Typer - CLI framework
  • Rich - Terminal formatting
  • Packaging - Version parsing (PEP 440, PEP 508)

Made with ❤️ for Python developers and AI coding assistants

Metadata

Release files for pyconflict 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyconflict 2.0.0
File Size Uploaded Provenance Actions
pyconflict-2.0.0.tar.gz 31.5 kB With provenance Details for pyconflict-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyconflict 2.0.0
File Interpreter ABI Platform Actions
pyconflict-2.0.0-py3-none-any.whl Python 3 none any Details for pyconflict-2.0.0-py3-none-any.whl

Total release size: 66.6 kB

Release files / pyconflict-2.0.0.tar.gz

Download URL pyconflict-2.0.0.tar.gz
Size 31.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c6fdf6bb4f59712fd984bf38ff706b225ca6c824efc6196027222c7901839b38
BLAKE2b-256 checksum
How to use checksums
dc79c0b7a1e62ae2f6a7f9534bbbbff731a7a1c8fabf9b6201c2223b075ca049
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Release files / pyconflict-2.0.0-py3-none-any.whl

Download URL pyconflict-2.0.0-py3-none-any.whl
Size 35.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e26067fbffde1fa3a22769b18301d3d672de7f7df55fcc23d5df5be9643a90f0
BLAKE2b-256 checksum
How to use checksums
a0a2ae8e94bf89aa56964d508fdd901f79f855653e8d27d454ea68b8f2f30b0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

Security for pyconflict 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyconflict-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page