Make Your Code More Readable With The Magic Of Refactoring Using Sourcery

The Python Podcast.__init__ - Un pódcast de Tobias Macey

Categorías:

Summary Writing code that is easy to read and understand will have a lasting impact on you and your teammates over the life of a project. Sometimes it can be difficult to identify opportunities for simplifying a block of code, especially if you are early in your journey as a developer. If you work with senior engineers they can help by pointing out ways to refactor your code to be more readable, but they aren’t always available. Brendan Maginnis and Nick Thapen created Sourcery to act as a full time pair programmer sitting in your editor of choice, offering suggestions and automatically refactoring your Python code. In this episode they share their journey of building a tool to automatically find opportunities for refactoring in your code, including how it works under the hood, the types of refactoring that it supports currently, and how you can start using it in your own work today. It always pays to keep your tool box organized and your tools sharp and Sourcery is definitely worth adding to your repertoire. Announcements Hello and welcome to Podcast.__init__, the podcast about Python and the people who make it great. When you’re ready to launch your next app or want to try a project you hear about on the show, you’ll need somewhere to deploy it, so take a look at our friends over at Linode. With the launch of their managed Kubernetes platform it’s easy to get started with the next generation of deployment and scaling, powered by the battle tested Linode platform, including simple pricing, node balancers, 40Gbit networking, dedicated CPU and GPU instances, and worldwide data centers. Go to pythonpodcast.com/linode and get a $100 credit to try out a Kubernetes cluster of your own. And don’t forget to thank them for their continued support of this show! We’ve all been asked to help with an ad-hoc request for data by the sales and marketing team. Then it becomes a critical report that they need updated every week or every day. Then what do you do? Send a CSV via email? Write some Python scripts to automate it? But what about incremental sync, API quotas, error handling, and all of the other details that eat up your time? Today, there is a better way. With Census, just write SQL or plug in your dbt models and start syncing your cloud warehouse to SaaS applications like Salesforce, Marketo, Hubspot, and many more. Go to pythonpodcast.com/census today to get a free 14-day trial. Your host as usual is Tobias Macey and today I’m interviewing Nick Thapen and Brendan Maginnis about Sourcery, an advanced refactoring engine that cleans up your code as you work Interview Introductions How did you get introduced to Python? Can you start by giving an overview of what Sourcery is? What was your motivation for building a system for performing automated refactoring? What are your goals and priorities with Sourcery? There are a number of services that aim to automate portions of the developer workflow, such as code completions, quality checks, refactoring, etc. What was lacking in the existing tooling that made Sourcery a necessary project? How does Sourcery compare with some of the other services that offer AI or ML powered assistance? (e.g. Kite, Tab9, Codata(?)) What was your reasoning for focusing solely on Python for your refactoring, rather than trying to support multiple language targets? Can you give some examples of the types of refactoring that you are able to automate? Can you describe how Sourcery is implemented? What are some of the ways that the system has changed or evolved in design and/or scope? What are some examples of the types of refactorings that Sourcery is ill-suited for and which still require manual intervention? What is involved in adding support for a new editor? How much variation is there in terms of implementation or available functionality across editors? How has the introduction of the Language Server Protocol influenced your approach to editor integration? What are some of the most interesting, unexpected, or challenging lessons that you have learned while working on Sourcery? When is Sourcery the wrong choice? What do you have planned for the future of Sourcery Keep In Touch Nick LinkedIn @nthapen on Twitter Brendan LinkedIn @brendan_m6s on Twitter brendanator on GitHub Picks Tobias The Croods: New Age Nick The Magicians TV Series Brendan David Copperfield by Charles Dickens Closing Announcements Thank you for listening! Don’t forget to check out our other show, the Data Engineering Podcast for the latest on modern data management. Visit the site to subscribe to the show, sign up for the mailing list, and read the show notes. If you’ve learned something or tried out a project from the show then tell us about it! Email [email protected]) with your story. To help other people find the show please leave a review on iTunes and tell your friends and co-workers Join the community in the new Zulip chat workspace at pythonpodcast.com/chat Links Sourcery IBM RPG Delphi Java Scala PyTorch Podcast Episode NLP == Natural Language Processing Tensorflow Language Server Protocol Kent Beck Martin Fowler MyPy Clojure Lisp Abstract Syntax Tree ASTroid Podcast Episode Rope Sans I/O pre-commit framework Podcast Episode The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA

Visit the podcast's native language site