<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sourcery &#8211; iAIFeed</title>
	<atom:link href="https://www.iaifeed.com/tag/sourcery/feed" rel="self" type="application/rss+xml" />
	<link>https://www.iaifeed.com</link>
	<description>iAIFeed</description>
	<lastBuildDate>Sat, 19 Sep 2026 12:45:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.1</generator>

<image>
	<url>https://www.iaifeed.com/wp-content/uploads/2026/07/cropped-iaifeed1-80x80.png</url>
	<title>Sourcery &#8211; iAIFeed</title>
	<link>https://www.iaifeed.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Add Sourcery to CI and Enforce Refactor Rules</title>
		<link>https://www.iaifeed.com/how-to-add-sourcery-to-ci-and-enforce-refactor-rules</link>
					<comments>https://www.iaifeed.com/how-to-add-sourcery-to-ci-and-enforce-refactor-rules#respond</comments>
		
		<dc:creator><![CDATA[iamltlb]]></dc:creator>
		<pubDate>Sat, 19 Sep 2026 12:45:34 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Sourcery]]></category>
		<guid isPermaLink="false">https://www.iaifeed.com/how-to-add-sourcery-to-ci-and-enforce-refactor-rules</guid>

					<description><![CDATA[Running Sourcery only in your editor means half the team ignores it. This guide wires the CLI into GitHub Actions, sets a rule profile and keeps refactor traffic under control.]]></description>
										<content:encoded><![CDATA[<p><strong>You put Sourcery in CI by running the CLI on each pull request, generating a report, and failing the check only on rules your team agreed to enforce.</strong> The editor extension is per-developer; CI is where it becomes a team standard.</p>
<p>If your team already uses <a href="https://www.iaifeed.com/ai-tool/sourcery">Sourcery</a> locally but pull requests still come in with the same issues, this is the missing half.</p>
<h2>How do you run Sourcery in GitHub Actions?</h2>
<p>Add a workflow that installs the CLI and runs a review against the base branch. The core steps:</p>
<pre><code>- uses: actions/setup-python@v5
  with: { python-version: '3.12' }
- run: pip install sourcery-cli
- run: sourcery review --diff "origin/${{ github.base_ref }}...HEAD"</code></pre>
<p>The <code>--diff</code> flag matters. Reviewing the whole repo on every PR is slow and drowns the real changes in legacy noise. Restrict it to the lines the PR actually touches.</p>
<h2>Which rules should you enforce versus warn?</h2>
<p>Split rules into two buckets and treat them differently:</p>
<table>
<tr>
<th>Bucket</th>
<th>Rules</th>
<th>CI behavior</th>
</tr>
<tr>
<td>Enforce</td>
<td>Unused imports, dead code, shadowed names</td>
<td>Fail the check</td>
</tr>
<tr>
<td>Warn</td>
<td>Comprehension rewrites, control-flow changes</td>
<td>Comment only</td>
</tr>
</table>
<p>Dead code and unused imports are safe to block — they are unambiguous. Comprehension rewrites are a style call that varies by file, so never fail a build over them.</p>
<h2>How do you keep refactor PRs reviewable?</h2>
<p>Sourcery in CI should be a reporter, not a committer. If you also auto-apply its fixes, you get pull requests mixing feature work with dozens of unrelated refactors, and reviewers cannot tell which lines are functional.</p>
<p>Keep them separate. Merge the feature PR first, then run a standalone cleanup PR generated purely by Sourcery. A cleanup PR that changes only refactors is trivial to approve. Mixed PRs are not.</p>
<h2>What about the paid tier in CI?</h2>
<p>The CLI runs locally for free, but team features — shared rule config, PR comments, dashboards — sit in the paid plan. For a small team, the free CLI plus a GitHub Actions step reproduces most of the value at zero cost. The paid tier is worth it when you want per-repo rule profiles without maintaining YAML yourself.</p>
<h2>Does Sourcery work outside Python?</h2>
<p>No. It is Python-only, and that is a hard boundary. On a polyglot repo, keep it scoped to your <code>.py</code> paths and use a different tool for the rest. Trying to force it across languages just produces false silence on the non-Python code.</p>
<h2>Quick Summary</h2>
<ul>
<li>Run <code>sourcery review --diff</code> in GitHub Actions against the base branch.</li>
<li>Fail CI only on unambiguous rules: unused imports, dead code, shadowed names.</li>
<li>Never auto-commit refactors into a feature PR — keep cleanup PRs separate.</li>
<li>The free CLI covers CI basics; team dashboards and shared configs are paid.</li>
<li>Sourcery is Python-only; scope it to <code>.py</code> paths on polyglot repos.</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.iaifeed.com/how-to-add-sourcery-to-ci-and-enforce-refactor-rules/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Refactor Python Code Automatically with Sourcery</title>
		<link>https://www.iaifeed.com/how-to-refactor-python-code-automatically-with-sourcery</link>
					<comments>https://www.iaifeed.com/how-to-refactor-python-code-automatically-with-sourcery#respond</comments>
		
		<dc:creator><![CDATA[iamltlb]]></dc:creator>
		<pubDate>Sat, 19 Sep 2026 12:45:13 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Sourcery]]></category>
		<guid isPermaLink="false">https://www.iaifeed.com/how-to-refactor-python-code-automatically-with-sourcery</guid>

					<description><![CDATA[Sourcery reviews your Python code as you write it and suggests refactors you can apply in one click. Here is how to install it, what its rules change, and where it goes too far.]]></description>
										<content:encoded><![CDATA[<p><strong>Sourcery is a Python code-review assistant that runs in your editor and on pull requests, suggesting concrete refactors you apply with one click.</strong> Install the VS Code or PyCharm extension, open a .py file, and it starts marking lines with suggested rewrites.</p>
<p>It is not a linter in the usual sense. A linter tells you what is wrong; Sourcery shows you the rewritten code. For Python teams without a style czar, that difference saves real review time.</p>
<h2>How do you install Sourcery?</h2>
<p>Pick one editor and start there:</p>
<ol>
<li>Install the Sourcery extension from the VS Code marketplace or the PyCharm plugin gallery.</li>
<li>Sign in with a free account when the extension prompts you.</li>
<li>Open any Python file — suggestions appear as underlined code with a lightbulb.</li>
</ol>
<p>There is also a CLI, <code>sourcery review .</code>, that scans a whole project and prints findings. Run it in a throwaway branch the first time; on an old codebase the output is long.</p>
<h2>What does Sourcery actually change?</h2>
<p>Four categories dominate:</p>
<ul>
<li><strong>Comprehensions</strong> — turning a <code>for</code> loop that builds a list into a list comprehension.</li>
<li><strong>Modern syntax</strong> — f-strings instead of <code>.format()</code>, <code>dict | other</code> instead of <code>dict.update()</code> in Python 3.9+.</li>
<li><strong>Dead code</strong> — unused imports, unreachable branches, redundant else after return.</li>
<li><strong>Control flow</strong> — collapsing nested ifs, using <code>any()</code>/<code>all()</code> instead of flag variables.</li>
</ul>
<p>Each suggestion shows a before/after diff, so you see exactly what lands. That is more useful than a rule name like <code>C401</code>.</p>
<h2>Is Sourcery free for solo developers?</h2>
<p>Yes — the base product is free for individual use and open source. A paid team tier adds pull-request reviews, shared rule configuration and analytics. For a solo dev, the free tier is genuinely enough; the paid features matter once you want the same rules enforced on everyone&#8217;s code.</p>
<h2>Where does Sourcery push too hard?</h2>
<p>Comprehension suggestions are the main offender. A loop with a side effect, a log line, or a non-trivial condition becomes a dense one-liner that is technically shorter and harder to read. Accept the rewrite, then read it out loud — if you have to trace it twice, revert and dismiss the rule for that file.</p>
<p>It also lags new syntax. On a codebase full of match statements or <code>ExceptionGroup</code>, expect fewer relevant suggestions than the marketing implies.</p>
<h2>Quick Summary</h2>
<ul>
<li>Sourcery is a Python refactoring assistant for VS Code, PyCharm and the CLI.</li>
<li>It suggests comprehensions, modern syntax, dead-code removal and control-flow cleanup.</li>
<li>Free for individuals and open source; a paid team tier adds PR reviews.</li>
<li>Its comprehension rewrites can hurt readability — review each one.</li>
<li>Run <code>sourcery review .</code> on a throwaway branch the first time.</li>
</ul>
<p>For a broader review pass on Python pull requests, pair it with <a href="https://www.iaifeed.com/ai-tool/codeant-ai">CodeAnt AI</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.iaifeed.com/how-to-refactor-python-code-automatically-with-sourcery/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
