redbaron icon indicating copy to clipboard operation
redbaron copied to clipboard

Bottom-up approach to refactoring in python

Results 93 redbaron issues
Sort by recently updated
recently updated
newest added

I wrote one script with readbaron to remove code comments. ``` from redbaron import RedBaron def remove_comments_with_redbaron(source_py_file): with open(source_py_file, 'r', encoding='utf-8') as file: red = RedBaron(file.read()) comments = red.find_all('comment') for...

Dear RedBaron Support, I'm currently working on modifying an url.py file in django project using RedBaron. This file already contains two FromImportNode nodes. I'm attempting to add a new import...

![error](https://user-images.githubusercontent.com/30893757/64582108-26855f80-d3bf-11e9-85e8-430e7bd6ba26.png) here is my code: ```python async def request( self, method: Text = "post", subpath: Optional[Text] = None, content_type: Optional[Text] = "application/json", return_method: Text = "json", **kwargs: Any ): """Send...

While checking some code related to #190 I've discovered another bug. Let me start with a demo: ```python from pathlib import Path from redbaron import RedBaron src = Path('demo.py').read_text() fst...

Version: `0.9.2` Test Case: ```python from redbaron import RedBaron RedBaron("[*[1,2,3]]")] ``` gives the following error: ``` ParsingError: Error, got an unexpected token STAR here: 1 [*

Quite a lot of work, we need to list/detect common situation where we could find an identation in a CommaList and see how we have to behave. Here is an...

Does redbaron allow to sort functions by their usage? Also see https://stackoverflow.com/questions/76611154/how-to-automatically-sort-functions-in-classes-by-their-usage

This syntax works fine in python: ``` def foo(a, /, b): pass ``` but redbaron fails to parse it: ``` >>> redbaron.RedBaron("def foo(a, /, b): pass") Traceback (most recent call...

`with (context1 as c1, context2 as c2)` does not work. ``` >>> import redbaron >>> redbaron.RedBaron(''' ... with (open("a.txt", "w") as a, open("b.txt", "w") as b): ... print(1) ... ''')...

The walrus operator which was added in Python 3.8 (`:=`) is not supported: ``` >>> import redbaron >>> redbaron.RedBaron(''' ... if foo := True: ... print(foo) ... ''') Traceback (most...