Keep Your Code Clean And Maintainable Using Static Analysis With Flake8
The Python Podcast.__init__ - Podcast autorstwa Tobias Macey
Kategorie:
Summary When you are writing code it is all to easy to introduce subtle bugs or leave behind unused code. Unused variables, unused imports, overly complex logic, etc. If you are careful and diligent you can find these problems yourself, but isn’t that what computers are supposed to help you with? Thankfully Python has a wealth of tools that will work with you to keep your code clean and maintainable. In this episode Anthony Sottile explores Flake8, one of the most popular options for identifying those problematic lines of code. He shares how he became involved in the project and took over as maintainer and explains the different categories of code quality tooling and how Flake8 compares to other static analyzers. He also discusses the ecosystem of plugins that have grown up around it, including some detailed examples of how you can write your own (and why you might want to). 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 Anthony Sottile about Flake8 Interview Introductions How did you get introduced to Python? Can you start by giving an overview of what Flake8 is and how you got involved with the project? There are a variety of tools available for checking or enforcing code quality. How would you characterize Flake8 in comparison to the other options? What do you see as the motivating factors for individuals or teams to integrate static analysis/linting in their toolchain and workflow? What are some of the challenges that might prevent someone from adopting something like Flake8? How can developers add Flake8 to an existing project without spending hours or days fixing all of the violations? Can you describe the overall design and implementation of Flake8? How has the design and goals of the project changed or evolved? There are a wide array of plugins for Flake8. What is involved in adding new functionality or linting rules? What capabilities does Flake8 provide that make it a viable platform for building plugins? What are some of the limitations of Flake8 as a platform? What do you see as the factors that have contributed to the widespread usage of Flake8 and the large number of available plugins? What challenges does that pose as a maintainer of Flake8? What are some of the other tools that you see developers use alongside Flake8 to help manage code quality and style enforcement? What are some of the most interesting, innovative, or unexpected ways that you have seen Flake8 and its plugin ecosystem used? What are the most interesting, unexpected, or challenging lessons that you have learned while working on Flake8? When is Flake8 the wrong choice? What do you have planned for the future of Flake8? Keep In Touch @codewithanthony on Twitter asottile on GitHub LinkedIn Picks Tobias SEVENEVES by Neal Stephenson Anthony pre-commit CI 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 Flake8 PyFlakes PyCodestyle McCabe pre-commit Podcast Episode PEP 484 MyPy Pylance Pyright Pylint Black yapf autopep8 pyupgrade isort reorder-python-imports Static Analysis pydocstyle autoflake pyproject.toml Abstract Syntax Tree Concrete Syntax Tree Dagster The intro and outro music is from Requiem for a Fish The Freak Fandango Orchestra / CC BY-SA