Sourcery AI
p/sourcery-ai
Instant Python refactoring
Tim Gilboy

Sourcery 2.0 — Continuous code review to make your code more maintainable

Featured
69
•
Sourcery makes sure all of your code is following best practices from standard Pythonic rules to issues that pop up during code reviews. Add to your IDE to get instant feedback, use the CLI to review existing code, or integrate it into your CI.
Replies
Best
Tim Gilboy
Hey Product Hunt 👋 - @brendan_maginnis, @nick_thapen, and I are back and we’re very excited to be sharing the new version of Sourcery with you all. Sourcery sits in the background while you work analyzing your code, finding problems, and suggesting improvements to make sure it’s following best practices. You can think of it as the first layer of code review, catching mistakes before a human reviewer needs to take a look. As always - Sourcery runs fully locally, so your code is private. Here’s what’s new: 1. Extend Sourcery to handle your best practices. You shouldn’t have to make the same comment more than one time in a code review. When you see issues coming up frequently you can create a Sourcery rule, and these issues will get caught for your whole team before the code is merged. 2. Leverage Pre-Built Rulesets. We’ve taken the Google Python Style Guide and made it available as a (set of Sourcery rules). Pick and choose the rules that make sense for you (and customize them how you want) or add in the full ruleset. 3. CLI for bulk review. We’ve extended the Sourcery CLI to make it more powerful (and much quicker) for reviewing multiple files, or your entire repo. With a single command you can scan hundreds of files, identify common issues, and make bulk changes to improve your code. 4. Review every commit with Sourcery in CI. Let Sourcery handle the first layer of your code reviews by adding it to your CI. Sourcery is easily configurable to run only on changed code to help cut down on noise from legacy code. Anyone can start using Sourcery for free, and teams coming through ProductHunt with promo code PRODUCTHUNT2022 can use the full team version (includes full use in CI or as a pre—commit hook - see more details at https://sourcery.ai/team/) for free for 2 months.
Sean Kruzel
I use sorcery everyday for the last 2 years. I love combining it with GitHub Copilot to really speed up my development process! For example CoPilot generates code, then Sourcery improves it and fits it into our style guides. Finally there is nothing quite as satisfying as using the CLI to refactor a huge out-of-date repo. @brendan_maginnis @nick_thapen @tim_sourcery
Brendan Maginnis
Thanks @seankruzel! That's really cool how you use Sourcery and CoPilot together 🚀
Kyle Lawson
This product is great! The suggestions are helpful while still being easy enough to ignore if you have reason to. It has become such a natural piece of my IDE workflow now that I sometimes forget it's an extension
Tim Gilboy
@kylelaws0n thanks - we love hearing feedback like this!!
Reka
@kylelaws0n Thanks a lot. "It has become such a natural piece of my IDE workflow now that I sometimes forget it's an extension" That's quite a compliment. :-) We're looking forward to your feedback to the new & improved CLI.
Rishabh Agrawal
A quick question. How is it different from Sonarqube which provides a full fledged solution with linting, security and code coverage as well?
Reka
@rishabh_agrawal2 Good question. SonarQube is also a great code quality tool. There's an overlap between their functionalities, but there are also some differences. 1) Automated fixes Sourcery provides automated fixes for more than 100 common code quality issues. You can apply these immediately in your IDE as you type. Or you can fix dozens of issues at once in the command line. https://docs.sourcery.ai/Guides/...
Reka
@rishabh_agrawal2 2) Custom rules With Sourcery, you can define your own rules specific to your codebase. For example: * Check the dependencies between the packages of your project. * Project specific naming conventions. * Getting rid of deprecated code https://docs.sourcery.ai/Guides/... https://docs.sourcery.ai/Guides/...
Thomas Jones
Sounds good ... can I use Sourcery on legacy projects, or will it just overwhelm me with issues ... ?
Tim Gilboy
@tjamesjones good question! You can handle legacy code in two ways: 1. Do a full project review to identify all existing issues. We recommend doing this with our command line interface (https://docs.sourcery.ai/Guides/...). You can run `sourcery review ` to check all of your existing code and get a baseline for what issues you have. You can then choose which of those you want to fix right away and which you want to wait to deal with. 2. Set up Sourcery in your CI (https://docs.sourcery.ai/Guides/...) or as a pre-commit hook (https://docs.sourcery.ai/Guides/...) and set it to only review changed code using the --diff option. Then Sourcery will only look at the changed code and only suggest changes on those.
JĂ©rĂ´me Bau
Love the product and the team. Our team has been using it for quite some time. I'm especially excited about the best practices and rulesets.
Johannes Hund
Gave it a spin and am amazed! Not much into python though. Any plans on supporting other languages? Golang maybe? could probably be among the more accessible ones and would be great to have! I would be very happy to see a tool like this for JS/Typescript or even Rust, but I assume that's more ambitious.
Tim Gilboy
@johanneshund1 thank you! We're planning on adding in support for additional languages and are aiming for early next year for the first one. We ultimately want to support a broad array of languages including Golang, JS, & Rust
Reka
@johanneshund1 Thanks a lot. Additional languages are definitely on our roadmap. Right now, we're planning to release a second language in early 2023 and then adding more languages successively. We haven't decided on the 2nd language yet, but JavaScript and Golang are among the candidates.
Joris Hoendervangers
Trying Sourcery for a few weeks now and I've been very impressed. It suggested useful refactorings and it works blazingly fast (with the PyCharm plugin). Probably will start using this while teaching as well!
Brendan Maginnis
Thanks @hoenie! We've heard from a few users that Sourcery is a great teaching tool, as it shows you best practices as you're writing code.
Hannu Kokko
Have been using Sourcery Pro since year and a half when I discovered it. It has been extremely useful for making sure codebase stays Pythonic. Using it multiple times a day both at work and hobby projects. I love the configurability even in the Pro version. Have been eyeing the Teams version - maybe soon.
Reka
@hannu_kokko Thanks a lot for the nice feedback. I'm curious: Which configuration options do you use? How is your setup different for work and hobby projects? Regarding the Teams version: The command line tool is also available in the Pro version now. Hopefully, this makes it easier to try out the Teams features and to evaluate whether this would be useful for your team as well. If you have any questions about this, please reach out to us.
Hannu Kokko
@reka4096 Not using all the Google rules. From the standard rules: Off the cuff: not using the rule/s that results in extend being used in python code, I find that extend did not make code clearer. Not using the walrus rules - current way that results from that refactoring does not make it clearer - there are places for walrus but these have not come up so far.
Reka
@hannu_kokko Thanks for the insight, that's very interesting. Regarding walrus: Do you have a rule of thumb when you prefer using it and when not?
Tomáš Pytel
Sourcery is an absolute gem in this area. I'm using it since the beginning and I will tell you, there is no better solution than that. It is in my must-have plugins for every IDE I'm using. Godspeed Sourcery 👍🚀
Brendan Maginnis
Thanks for the great comments @tomas_pytel!
Varun Razora
Can i integrate with android studio and VS?
Tim Gilboy
@varunrazora for now we're Python only, so don't have direct support for android studio or visual studio (but we do have support for visual studio code). As we expand to add more languages we'll also expand what IDEs we support
Varun Razora
@tim_sourcery VS and Android studio is one of the major player in IDE. I would wait for the update from you guys soon. All the best man.
Ash Rahman 🎮
Looks helpful. Would need to try it. Best wishes on the launch!
Tim Gilboy
@ashrahman Thanks Ash! I'd love to hear your feedback once you get a chance to try it out. Please reach out at any time if you have any questions
M.H. Lines
Hey Tim - We'd love to look into this. Can you reach out?
Tim Gilboy
@m_h_lines definitely! I just connected with you on LinkedIn, but let me know if there's a better way to get in touch
Lukas Kemkes
Love the progress, team Sourcery! Excited for our engineering team to test this out 🚀
Tim Gilboy
@lukas_kemkes thank you! Let us know what you think :)
Adil shaikh
Congrats on the launch
Tim Gilboy
@kaira_khan thank you!
Reka
@kaira_khan Thanks a lot.
Pranav Prakash
We have been using Sourcery for more than a year now. Our team is able to find some really good and time saving optimisations using this. I would recommend this.
Brendan Maginnis
@pranavprakash Thanks Pranav, really glad Sourcery is helpful for you
Shushant Lakhyani
This is a veery helpful tool for developers!
Reka
@shushant_lakhyani Thanks a lot.
Dr. Christian Poensgen
Love it! Also, I'm a bit curious: Do you use Sourcery for Sourcery’s code?
Tim Gilboy
@dr_christian_poensgen we do! We make sure all our code is following our core rules (standard Python best practices) and then we've built out a bunch of additional rules to tackle things like making sure certain sections of our codebase are following the boundarires we want in our monorepo, making sure we're not using/extending deprecated classes in any way, enforcing that we use helper functions when we can, etc. Basically anytime something comes up more than once during a code review we try to turn it into a rule for ourselves in Sourcery Each of us has it in our IDE (including @brendan_maginnis in Vim) and then we also have it built into our IDE.
Usama Ejaz
Great product! Congratulations on the launch!
Reka
@usamaejaz Thanks a lot. We're looking forward to hearing your feedback.
Martin Gould
So excited to see the progress! Do you also plan to support any other languages in the future?
Tim Gilboy
@emmgee thanks for the support! We are planning on adding in additional language support in the near future. Right now we're targeting early next year for our first additional language and then adding in more languages after that. Are there any specific languages we should be prioritizing supporting for you?
Gregoire Lecomte
Congratulation Sourcery!!! What languages will you support?
Tim Gilboy
@gregoire_lecomte thank you! We're looking to start supporting new languages early next year, but we haven't fully settled on which the first new languages will be. Any preferences?