1,949 karma · joined Dec 27, 2020 (5y ago) · 250 submissions
comment 5y ago · link · parent
comment 5y ago · link · parent
The real start point for this project was to find / replace all type(<literal>)'s in CPython codebase with type(type(<literal>)) (e.g type('') would become type(str)) which is very light weight transformation, and I was able to write a script which did it without having any major problems about style on over 2000 files. Here it is for the reference: https://github.com/isidentical/refactor/blob/master/examples...
Also one thing to note here is that; in the last couple of years, thanks to black (and yapf), the adoptance of code formatters have really increased which is very nice for custom refactoring tools like refactor since the end-code would be refactored anyways so that means if you convert a multi line call, or a list to a single line version then the formatter you use probably reformat that segment anyways.
But thanks for authoring Bowler! It is a very cool project.
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
248.
Show HN: Python Source Code Refactoring Toolkit via AST(github.com ↗)
110 points · by treesciencebot · 5y ago · 33 comments
comment 5y ago · link · parent
Though personally I would dislike this, since every time somebody mentioned about type hints they commented on the property of them not causing 'ANY RUNTIME EFFECTS'. Of course the specializations come with guards, so if the annotation is wrong it is just going to work as a mispredicted option and fallback to the generic implementation though the concept of them changing the initial layer of optimizations is not something that I'd rather see in 'the Python language. PEP 563 even moves this properties forward and renders them totally uneffective in the eyes of the interpreter.
250.
Should we say stop to the syntactical growth of Python?(tree.science ↗)
3 points · by treesciencebot · 5y ago · discuss