{"id":24292349,"url":"https://github.com/jvllmr/rustpython-unparser","last_synced_at":"2025-09-25T17:31:06.061Z","repository":{"id":270347256,"uuid":"906766659","full_name":"jvllmr/rustpython-unparser","owner":"jvllmr","description":"A complete unparser for rustpython-parser ASTs","archived":false,"fork":false,"pushed_at":"2025-01-14T18:45:52.000Z","size":111,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-01-14T20:07:10.459Z","etag":null,"topics":["ast","rustpython","unparser"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jvllmr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-21T20:59:03.000Z","updated_at":"2025-01-14T18:45:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"66bc98a6-03e0-47e0-98bf-3dc64d2599f7","html_url":"https://github.com/jvllmr/rustpython-unparser","commit_stats":null,"previous_names":["jvllmr/rustpython-unparser"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvllmr%2Frustpython-unparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvllmr%2Frustpython-unparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvllmr%2Frustpython-unparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jvllmr%2Frustpython-unparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jvllmr","download_url":"https://codeload.github.com/jvllmr/rustpython-unparser/tar.gz/refs/heads/dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234224507,"owners_count":18798844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ast","rustpython","unparser"],"created_at":"2025-01-16T15:29:48.483Z","updated_at":"2025-09-25T17:31:06.055Z","avatar_url":"https://github.com/jvllmr.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rustpython-unparser\n\n[![Crates.io Downloads (latest version)](https://img.shields.io/crates/dv/rustpython-unparser)](https://crates.io/crates/rustpython-unparser)\n[![Crates.io Version](https://img.shields.io/crates/v/rustpython-unparser)](https://crates.io/crates/rustpython-unparser)\n![CI Badge](https://github.com/jvllmr/rustpython-unparser/actions/workflows/test.yml/badge.svg)\n\nA complete unparser for rustpython-parser ASTs.\n\n## Acknowledgement\n\nI created this library because I quickly needed a way to turn rustpython-parser ASTs back to some form of Python source code. Since the unparser contained within rustpython-ast only supports expressions and not statements, I started implementing my own unparser by taking heavy inspiration from rustpython's unparser and the unparser in the python standard library. Therefore, most credit goes to the respective teams behind the ast standard library module and RustPython. I only glued the parts I needed together to a complete unparser in this repository.\n\nI personally don't use this crate anymore since I switched over to using the ruff's internal AST, but I will still accept PRs.\nFeel free to contribute if you find out that you are missing something.\n\n## Contributing\n\nYou can already help a lot by reporting issues with generated code. If you find an issue,please provide example code of the original source and the unparsed source with a concise explanation.\n\nIf you would like to fix the issue yourself, you can create an example in one of the matching files in `test_files` or create a new file with your example if you think your example does not fit into any of the existing files. Then you can run the tests with `cargo t` and verify your changes by viewing your unparse example in the `test_files_unparsed` directory. After verifying your changes you can create a Pull Request. If your change is linked to a GitHub issue, please provide a comment in the form of `# \u003clink to github issue\u003e` next to your example.\n\n## Simple usage example\n\n```rust\nuse rustpython_unparser::Unparser;\nuse rustpython_parser::ast::Suite;\nuse rustpython_parser::Parse;\n\nfn main() {\n    // ...\n    let unparser = Unparser::new();\n    let stmts = Suite::parse(source_str, file_path);\n    for stmt in \u0026stmts {\n        unparser.unparse_stmt(stmt);\n    }\n    let new_source = unparser.source;\n    // ...\n}\n```\n\n## Transformer\n\nThis crate also contains a transformer trait for easy transformation of ASTs with the possibility of removing nodes. Enable the `transformer` feature to use it. It is similar to rustpython-ast's visitor, with the difference that a visit functions always return `Option\u003c...\u003e` and statements/expressions are passed as mutable.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvllmr%2Frustpython-unparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjvllmr%2Frustpython-unparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjvllmr%2Frustpython-unparser/lists"}