{"id":8165,"library":"fissix","title":"Fissix","description":"Fissix is a Python library that monkeypatches and overrides the default behavior of the standard library `lib2to3`. It provides an enhanced and actively maintained version of `lib2to3`, primarily used for transforming Python code, especially for backporting `2to3` fixes for Python 3 codebases. It aims to be a drop-in replacement for `lib2to3`'s code transformation utilities. The current version is 24.4.24, and it often sees updates in conjunction with CPython development.","status":"active","version":"24.4.24","language":"python","source_language":"en","source_url":"https://github.com/google/fissix","tags":["code-transformation","lib2to3","refactoring","AST"],"install":[{"cmd":"pip install fissix","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"`fissix` provides its own implementation of core `lib2to3` components. While `fissix` monkeypatches `lib2to3`, it's best practice to import directly from `fissix` modules to ensure you're using the enhanced versions, especially for classes like `RefactoringTool`.","symbol":"RefactoringTool","correct":"from fissix.refactor import RefactoringTool"},{"note":"The `fissix.main` module provides the command-line interface and entry point, similar to `lib2to3.main`. Use `fissix.main.main()` for command-line-like execution or `RefactoringTool` for programmatic transformations.","symbol":"main","correct":"import fissix.main"}],"quickstart":{"code":"import io\nfrom fissix.refactor import RefactoringTool, get_all_fix_names\n\n# Get all available fixers provided by fissix\nall_fixer_names = get_all_fix_names()\n\n# Create a RefactoringTool instance with the desired fixers.\n# By default, get_all_fix_names() includes standard 2to3 fixes and fissix enhancements.\ntool = RefactoringTool(all_fixer_names)\n\n# Source code to transform\noriginal_code = \"\"\"\nprint \"Hello, world!\"\nif True:\n    pass # A comment\n\"\"\"\n\n# Apply the transformation to the string.\n# refactor_string returns a Node object representing the transformed code tree.\ntransformed_tree = tool.refactor_string(original_code, \"<string>\")\n\n# Convert the transformed tree back to a string representation\ntransformed_code = str(transformed_tree)\n\nprint(\"Original code:\\n\" + original_code)\nprint(\"\\nTransformed code:\\n\" + transformed_code)","lang":"python","description":"This quickstart demonstrates how to programmatically use `fissix`'s `RefactoringTool` to apply all available code fixers to a given string. This is the core mechanism for transforming Python code using `fissix` without relying on file I/O or the command-line interface."},"warnings":[{"fix":"Ensure `fissix` is imported early in your application's lifecycle if you intend for its monkeypatching to take effect globally. If conflicts arise, isolate `fissix` usage to specific contexts or consider alternatives if strict `lib2to3` behavior is required elsewhere.","message":"Fissix monkeypatches the standard library `lib2to3` module upon import. This can lead to unexpected behavior or conflicts if other libraries also attempt to modify `lib2to3` or rely on its exact default implementation before `fissix` is imported.","severity":"breaking","affected_versions":"All versions"},{"fix":"Review the `fissix` GitHub repository and documentation for specific changes or enhancements. Perform comprehensive regression tests when integrating `fissix` into existing `lib2to3`-reliant projects.","message":"`fissix` is a fork and enhancement of `lib2to3`. While it aims for full compatibility and improvement, subtle differences in behavior, available fixers, or parsing logic might exist compared to the vanilla `lib2to3` module. Always test thoroughly when migrating or expecting precise `lib2to3` parity.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure you are running `fissix` in a Python 3 environment. Its purpose is to provide an improved code transformation framework within Python 3.","message":"`fissix` is primarily designed for transforming Python 3 code or modernizing code that was originally Python 2 but intended for Python 3 environments. It is not a tool to run *on* a Python 2 interpreter to convert Python 2 source code to Python 3.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'24.4.24':63 '2to3':38 '3':42 'activ':24 'aim':45 'ast':79 'backport':37 'behavior':13 'code':34,56,75 'code-transform':74 'codebas':43 'conjunct':70 'cpython':72 'current':60 'default':12 'develop':73 'drop':50 'drop-in':49 'enhanc':22 'especi':35 'fissix':1,2 'fix':39 'lib2to3':18,28,54,77 'librari':6,17 'maintain':25 'monkeypatch':8 'often':66 'overrid':10 'primarili':29 'provid':20 'python':5,33,41 'refactor':78 'replac':52 'see':67 'standard':16 'transform':32,57,76 'updat':68 'use':30 'util':58 'version':26,61","created_at":"2026-04-16T17:00:46.421926+00:00","updated_at":"2026-04-16T17:00:46.421926+00:00","problems":[{"fix":"While `fissix` monkeypatches `lib2to3`, it's best to explicitly import fixers and utilities from `fissix` modules (e.g., `from fissix.fixes import fix_print` or `from fissix.fixer_util import Name`). If using `RefactoringTool`, pass the fully-qualified string name like `'fissix.fixes.fix_print'`.","cause":"You are attempting to access a fixer or utility module that is either specific to `fissix` or has been overridden by `fissix`, but you are trying to import it directly from the original `lib2to3.fixes` namespace.","error":"AttributeError: module 'lib2to3.fixes' has no attribute 'fix_xxx'"},{"fix":"This warning is expected and generally harmless when using `fissix`, as `fissix` aims to maintain and enhance `lib2to3`. It indicates Python's stance on the *standard library* `lib2to3`, not a problem with `fissix` itself. You can choose to suppress `DeprecationWarning` if it becomes too noisy, but it's important to understand its origin.","cause":"`fissix` is built on and extends `lib2to3`. Even when using `fissix`, the underlying (and now deprecated) standard library `lib2to3` module is still utilized, triggering Python's deprecation warning.","error":"RuntimeWarning: This application uses the lib2to3 module, which is deprecated in Python 3.x and scheduled for removal in Python 3.12."},{"fix":"If you need to call `fissix.main.main()` programmatically, wrap the call in a `try...except SystemExit` block to prevent your script from exiting. For purely programmatic code transformations without command-line behavior, it's generally better to use `fissix.refactor.RefactoringTool` directly.","cause":"`fissix.main.main()` is designed to mimic command-line execution and calls `sys.exit()` upon completion, including when an error occurs or invalid arguments are passed.","error":"SystemExit: 2 (or other non-zero exit code) when calling fissix.main.main()"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"24.4.24","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/amyreese/fissix","docs":null,"changelog":null,"pypi":"https://pypi.org/project/fissix/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}