LibCST
asmoses
LibCST | asmoses | |
---|---|---|
9 | 3 | |
1,428 | 38 | |
2.4% | - | |
8.5 | 7.8 | |
3 days ago | 8 months ago | |
Python | C++ | |
GNU General Public License v3.0 or later | GNU General Public License v3.0 or later |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
LibCST
- Show HN: Codemodder – A new codemod library for Java and Python
-
Package that graphs and exports jpeg of CST/AST?
LibCST: Seems to only show in terminal.
-
How to approach modifying source code programmatically?
While you can do this using ANTLR or any other lexing/parsing tool, it's honestly a bit of a pain. Whitespace and comments can go almost anywhere, even in the middle of expressions, so the grammar ends up becoming fairly messy. So, I'd recommend using a library that handles this for you, if at all possible. For example, if I wanted to code-mod Python I'd prob just use the LibCST library.
-
ruff is a fast Python linter written in Rust
I recommend https://github.com/Instagram/LibCST (which is currently implementing rust bindings)
-
How to handle line endings when writing files depending on OS?
I've been roughly copying some of the logic from the LibCST project. This struct in particular- https://github.com/Instagram/LibCST/blob/main/native/libcst/src/tokenizer/text_position/char_width.rs does a good job of normalizing the line endings of a str. The long way around you could mimic this construct, transform the str to normalized line endings, and then split on "\n" or make a somewhat more complicated transformer which turns a large str into a Vec (or Vec).
-
We're the core team behind the popular Python autoformatter: Black. AMA!
I myself am working on upgrading LibCST's parser engine to support the new syntax, and then am hoping we can rewrite Black's formatting rules in terms of LibCST's API. That's not a small amount of work, which is why we can't confidently say that's going to be the way forward.
-
Our Engineering Team Used Python's AST to Patch 100,000s of Lines of Code
Never used it but it appears that Facebook/Instagram have a format preserving CST library for Python: https://github.com/Instagram/LibCST
asmoses
-
Show HN: Codemodder – A new codemod library for Java and Python
Thanks for your reply!
I think they called it an FST "Full Syntax Tree", which is probably very similar to a CST "Concrete Syntax Tree". At the time that moses was written, Python's internal AST hadn't sufficient code to mutate sufficiently for moses' designs.
MOSES: Meta-Optimizing Semantic Evolutionary Search :
https://wiki.opencog.org/w/Meta-Optimizing_Semantic_Evolutio... :
> All program evolution algorithms tend to produce bloated, convoluted, redundant programs ("spaghetti code"). To avoid this, MOSES performs reduction at each stage, to bring the program into normal form. The specific normalization used is based on Holman's "elegant normal form", which mixes alternate layers of linear and non-linear operators. The resulting form is far more compact than, say, for example, boolean disjunctive normal form. Normalization eliminates redundant terms, and tends to make the resulting code both more human-readable, and faster to execute.
> The above two techniques, optimization and normalization, allow MOSES to outperform standard genetic programming systems.
https://github.com/opencog/asmoses
MOSES outputs Combo (a LISP), Python as an output transform IIUC, and now Atomese with asmoses, which links to a demo notebook: https://robert-haas.github.io/mevis-docs/code/examples/moses...
Evolutionary algorithm > Convergence: https://en.wikipedia.org/wiki/Evolutionary_algorithm#Converg...
/? mujoco learning to walk [with evolutionary selection / RL Reinforcement Learning]
-
Knowledge Graph Reasoning Based on Attention GCN
https://news.ycombinator.com/item?id=38744177 :
> - Indicate degree of confidence in annotation (note that AGI hypergraph systems have TruthValue and also AttentionValue, like attention networks
From " https://news.ycombinator.com/item?id=23787359 :
> How does this compare to MOSES (OpenCog/asmoses) or PLN? https://github.com/opencog/asmoses https://scholar.google.com/scholar?hl=en&as_sdt=0%2C43&q=%22... (2007)
From https://news.ycombinator.com/item?id=35810320 :
> Is there a better way to publish Linked Data with existing tools like LaTeX, PDF, or Word? Which support CSVW? Which support RDF/RDFa/JSON-LD?
What are some alternatives?
RedBaron - Bottom-up approach to refactoring in python
Ecosystem - You play God
Bowler - Safe code refactoring for modern Python.
black - The uncompromising Python code formatter
pasta - Library to refactor python code through AST manipulation.
ufmt - Safe, atomic formatting with black and µsort
instaviz - Instant visualization of Python AST and Code Objects
tbpatch - Token-based patch experiments
ruff - An extremely fast Python linter and code formatter, written in Rust.
lib3to6 - Build universally compatible python packages from a substantial subset of Python 3.8.
fastapi - FastAPI framework, high performance, easy to learn, fast to code, ready for production
intellij-blackconnect - IDEA plugin for using black[d] during Python development.