Pyrfecter: the secure online Python linter
What is linting?
Linting is the process of using a program (a "linter") to read code and find syntax errors, style inconsistencies, and improvement opportunities.
Linters generally use "static code analysis", which means that they read your code as text rather than running it directly, so linting is generally safe for code that has side-effects.
Why lint with Pyrfecter?
Why not! It's free, easy, and secure because your code never leaves your browser.
Pyrfecter can help you discover new Python code quality tools and is especially handy if you're looking to improve a single Python file.
How can linting improve your Python code?
Correctness
Linting can find errors in your code while you're writing it so you don't have to run your application before finding that it doesn't work because of a missing ,
or )
.
Check out the syntax errors example to see how Pyrfecter reports problems with your code using Pyflakes.
Readability
Linting can also help make your code more readable. wemake-python-styleguide
, for example, prevents variable names that are too short:
It is hard to understand what the variable means and why it is used, if its name is too short.
Take this code as an example:
co = "Apple"
dv = "iPhone"
cn = "New"
ds = {
"col": "white",
}
print(f"{cn} {ds['col']} {co} {dv}")
By the time we reach the print()
statement, it's easy to forget which variable is the company and which is the condition. (I even had those variables mixed up as I was writing that code example.)
Compare that example to the same code using complete variable names:
company = 'Apple'
device = 'iPhone'
condition = 'New'
details = {
"colour": "white",
}
print(f"{condition} {details['colour']} {company} {device}")
Faster code reviews
Inconsistent style can be distracting during code review, so using a linter to make code consistent across the team means more time spent reviewing logic and less time talking about style.
That saved time can go toward other code improvements, feature development, or bug fixes.
Performance
Some linters can recommend performance improvements and can find potential memory leaks in your Python code.