PCART is an automated tool designed to detect and repair Python API parameter compatibility issues. It is the first to achieve a fully automated process (end-to-end) that includes API extraction, code instrumentation, mapping, compatibility analysis, and repair and validation. PCART specializes in addressing API compatibility issues arising from parameter addition, removal, renaming, reordering, and the conversion of positional parameters to keyword parameters.
# 1. Create virtual environments with current and target library versions
# 2. Create config.json in Configure/ directory
# 3. Run PCART
python main.py -cfg your_config.jsonSee Configuration Guide for details.
- PCBench - Benchmark for Python API Parameter Compatibility Issues
- PCART Evaluation Results
| Type | Description |
|---|---|
| Parameter Addition | A new required parameter is added in the target version |
| Parameter Removal | A parameter used in the current version is removed in the target version |
| Parameter Renaming | A parameter is renamed between versions |
| Parameter Reordering | Parameters are reordered in the function signature |
| Positional to Keyword Conversion | A parameter that was positional-only becomes keyword-only |
- Linux (tested on Ubuntu 18.04.1) or Windows (tested on Windows 11)
- Python 3.9.12
- dill 0.3.7
- Python 3.x (version depends on your project requirements)
- dill 0.3.7
- Libraries at current version and target version respectively
| Environment | Purpose | Requirements |
|---|---|---|
| PCART | Runs the PCART tool itself | Python 3.9 + dill |
| currentEnv | Runs the target project (current library version) | Python 3.x + library (current version) + dill |
| targetEnv | Runs the target project (target library version) | Python 3.x + library (target version) + dill |
API/LibApi.py— Library API handlingChange/changeAnalyze.py— API compatibility analysis (isCompatible, addValueForAPI)Configure/— Configuration files (JSON configs for different projects)Example/— Example projects for testing PCARTExtract/— API extraction (getCall.py, getDef.py, extractCall.py, extractDef.py)LibAPIExtraction/— Pre-extracted library API definitionsMap/— API mapping (map.py, fuzzyMatch.py)Preprocess/preprocess.py— Code preprocessingRepair/repair.py— Compatibility issue repair and validationReport/— Repair reports (output)Script/— Repair helper scripts (addValueForAPI.py, codeUtils.py, dynamicMatch.py, verifySingle.py)Tool/tool.py— Utility functions (AST parsing, config loading, file operations)Load/loadData.py— Data loadingPath/getPath.py— Path handlingmain.py— Entry pointextractLibAPI.py— Library API extraction script
Determine the current version and target version of the third-party library that needs to be upgraded. Create virtual environments with both versions and install dill in both:
pip install dillCreate a JSON file in Configure/ directory:
Linux:
{
"projPath": "/home/usr/project",
"runCommand": "python run.py",
"runFilePath": "/home/usr/project/src",
"libName": "torch",
"currentVersion": "1.7.1",
"targetVersion": "1.9.0",
"currentEnv": "/home/usr/anaconda3/envs/v1",
"targetEnv": "/home/usr/anaconda3/envs/v2"
}Windows:
{
"projPath": "C:\\Users\\usr\\project",
"runCommand": "python run.py",
"runFilePath": "C:\\Users\\usr\\project\\src",
"libName": "torch",
"currentVersion": "1.7.1",
"targetVersion": "1.9.0",
"currentEnv": "C:\\Users\\usr\\anaconda3\\envs\\v1",
"targetEnv": "C:\\Users\\usr\\anaconda3\\envs\\v2"
}Notes:
runFilePath: Empty string""if entry file is in project root; set to subdirectory path if entry file is in a first-level subdirectorylibName: Use the name as it appears in code (e.g.,PILfor Pillow,sklearnfor scikit-learn)
python main.py -cfg your_config.jsonpython extractLibAPI.py -cfg your_config.json- Windows: Use backslashes (
\\) or forward slashes (/) in JSON paths - The tool automatically handles path separator conversion internally
python main.py -cfg Configure/Deep-Graph-Kernels.jsonFor detailed tutorials, troubleshooting, and advanced usage, please visit the PCART Wiki.
If you use PCART in your work, please cite:
@article{PCART_TSE2025,
author={Zhang, Shuai and Xiao, Guanping and Wang, Jun and Lei, Huashan and He, Gangqiang and Liu, Yepang and Zheng, Zheng},
journal={IEEE Transactions on Software Engineering},
title={PCART: Automated Repair of Python API Parameter Compatibility Issues},
year={2026},
volume={52},
number={3},
pages={723-753},
doi={10.1109/TSE.2025.3646150}
}
PCART's doxygen document is available here.
