ruff
LibCST
Our great sponsors
ruff | LibCST | |
---|---|---|
95 | 9 | |
26,504 | 1,415 | |
8.1% | 3.0% | |
10.0 | 8.6 | |
1 day ago | 9 days ago | |
Rust | Python | |
MIT License | 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.
ruff
-
Ask HN: High quality Python scripts or small libraries to learn from
I think I mention this all the time when this comes up, but I learned the most 'best practices' through using ruff.
https://docs.astral.sh/ruff/
I just installed and enabled all the rules by setting
-
Enhance Your Project Quality with These Top Python Libraries
Ruff is a Python linter that helps to identify and remove code smells. Over 700 built-in rules: Ruff includes native re-implementations of popular Flake8 plugins, like flake8-bugbear. And also built-in caching to avoid re-analyzing unchanged files.
-
Ask HN: What interesting project ideas you've got but have no time to work on?
Because the Python's "ast" modules is too slow, and lacks proper "format" feature (it has unparse but it removes comments, and forgets the current style completely). I use "ruff" a lot (https://github.com/astral-sh/ruff) which is in Rust. But I want to be able to implement fast custom linters in Go (linters that ruff / fixit lack, and Python linters lack or are too slow).
-
Rye: A Vision Continued
I think it’s interesting that rye uses ruff (https://github.com/astral-sh/ruff) for linting and formatting. That’s the right call, and it’s also correct to bundle that in for an integrated dev experience.
I had to guess, that’s the path that the Astral team would take as well - expand ruff’s capabilities so it can do everything a Python developer needs. So the vision that Armin is describing here might be achieved by ruff eventually. They’d have an advantage that they’re not a single person maintenance team, but the disadvantage of needing to show a return to their investors.
- An fast Python linter and code formatter, written in Rust
-
Smooth Packaging: Flowing from Source to PyPi with GitLab Pipelines
Adding more weight to ease of setup and configurability, the choice came down on flake8. It is easy to integrate, since its also available through pip and let’s you configure which standards you want to omit by simply stating them as a list via the --ignore switch. Moving to ruff appears quite smooth, so future updates may do so.
- Show HN: Marimo – an open-source reactive notebook for Python
-
AST-grep(sg) is a CLI tool for code structural search, lint, and rewriting
I confess I stole the pip recipe from Charlie :D
https://github.com/astral-sh/ruff/blob/main/.github/workflow...
-
Embracing Modern Python for Web Development
Ruff is an emerging tool in the Python ecosystem that describes itself as "an extremely fast Python linter and code formatter, written in Rust".
- Ruff: An fast Python linter and code formatter, written in Rust
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
What are some alternatives?
black - The uncompromising Python code formatter
RedBaron - Bottom-up approach to refactoring in python
mypy - Optional static typing for Python
Bowler - Safe code refactoring for modern Python.
pyright - Static Type Checker for Python
Pylint - It's not just a linter that annoys you!
pasta - Library to refactor python code through AST manipulation.
Flake8 - flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
ufmt - Safe, atomic formatting with black and µsort
pre-commit - A framework for managing and maintaining multi-language pre-commit hooks.
instaviz - Instant visualization of Python AST and Code Objects