Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ruff Python linter, remove flake8 #2312

Merged
merged 51 commits into from
Oct 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
077225d
git pre commit: rm checks of py files content
giampaolo Oct 3, 2023
bb4c12b
merge from master
giampaolo Oct 3, 2023
31411ba
get rid of flake8 (woha!)
giampaolo Oct 3, 2023
b8f19dc
add ruff config (taken from pyftpdlib)
giampaolo Oct 3, 2023
7604a18
run fixer for unnecessary parentheses
giampaolo Oct 3, 2023
6208d91
run fixer for unnecessary open(..., mode) param
giampaolo Oct 3, 2023
0877060
run fixer for unnecessary u'...' literal
giampaolo Oct 3, 2023
103b0c0
run fixer for unnecessary inheritance from (object)
giampaolo Oct 3, 2023
f0265eb
add fixes
giampaolo Oct 3, 2023
48825bd
run fixer for ternary operator
giampaolo Oct 3, 2023
a410b08
run fixer for use unpack tuple comprehension instead of list
giampaolo Oct 3, 2023
df059d0
run anoter fixer
giampaolo Oct 3, 2023
82a76fd
fix eval()
giampaolo Oct 3, 2023
94cda62
run anoter fixer
giampaolo Oct 4, 2023
c167bdc
run another fixer
giampaolo Oct 4, 2023
1ac91b7
run another fixer
giampaolo Oct 4, 2023
c6ac87c
run another fixer
giampaolo Oct 4, 2023
6c38c3b
run another fixer
giampaolo Oct 4, 2023
d67ff0f
fix str formatting
giampaolo Oct 4, 2023
718d148
run another fixer
giampaolo Oct 4, 2023
72c2540
run another fixer
giampaolo Oct 4, 2023
1adf92d
run another fixer
giampaolo Oct 4, 2023
5315b34
fix str format
giampaolo Oct 4, 2023
52db13d
run another fixer
giampaolo Oct 4, 2023
92f1f6b
run another fixer
giampaolo Oct 4, 2023
0447fe6
run another fixer
giampaolo Oct 4, 2023
adf6449
run another fixer
giampaolo Oct 4, 2023
770fb50
run another fixer
giampaolo Oct 4, 2023
793ae88
run another fixer
giampaolo Oct 4, 2023
c9805e5
run another fixer
giampaolo Oct 4, 2023
03b2a6d
run another fixer
giampaolo Oct 4, 2023
1eadac7
add 1 docstyle rule
giampaolo Oct 4, 2023
17b3a67
add 1 docstyle rule
giampaolo Oct 4, 2023
7f4baf7
add 1 docstyle rule
giampaolo Oct 4, 2023
aa335dc
add 1 docstyle rule
giampaolo Oct 4, 2023
f8d0b5d
add 1 docstyle rule
giampaolo Oct 4, 2023
df651a8
add 1 docstyle rule
giampaolo Oct 4, 2023
13df6f4
add 1 docstyle rule
giampaolo Oct 4, 2023
db3dc8c
git pre commit script: remove manual file content checks
giampaolo Oct 4, 2023
b9919eb
apply style change
giampaolo Oct 4, 2023
abfcc79
apply style change
giampaolo Oct 4, 2023
bb62e52
apply style change
giampaolo Oct 4, 2023
4e47fe8
fix tests
giampaolo Oct 4, 2023
5e96514
subprocess.Popen: don't use shell=True
giampaolo Oct 4, 2023
a395cd0
add rule
giampaolo Oct 4, 2023
c90bbd4
small refact
giampaolo Oct 4, 2023
4407cb6
get rid of isort
giampaolo Oct 4, 2023
ddca4db
try to fix win test
giampaolo Oct 4, 2023
0fdfe80
fix syntax err
giampaolo Oct 4, 2023
db91beb
expand make clean
giampaolo Oct 4, 2023
5058281
update HISTORY
giampaolo Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add 1 docstyle rule
giampaolo committed Oct 4, 2023
commit 1eadac7b5c347aceef5a5b1f7b2868e3aeee04db
5 changes: 5 additions & 0 deletions psutil/_common.py
Original file line number Diff line number Diff line change
@@ -280,6 +280,7 @@ class Error(Exception):
"""Base exception class. All other psutil exceptions inherit
from this one.
"""

__module__ = 'psutil'

def _infodict(self, attrs):
@@ -313,6 +314,7 @@ class NoSuchProcess(Error):
"""Exception raised when a process with a certain PID doesn't
or no longer exists.
"""

__module__ = 'psutil'

def __init__(self, pid, name=None, msg=None):
@@ -329,6 +331,7 @@ class ZombieProcess(NoSuchProcess):
On Linux all zombie processes are querable (hence this is never
raised). Windows doesn't have zombie processes.
"""

__module__ = 'psutil'

def __init__(self, pid, name=None, ppid=None, msg=None):
@@ -339,6 +342,7 @@ def __init__(self, pid, name=None, ppid=None, msg=None):

class AccessDenied(Error):
"""Exception raised when permission to perform an action is denied."""

__module__ = 'psutil'

def __init__(self, pid=None, name=None, msg=None):
@@ -352,6 +356,7 @@ class TimeoutExpired(Error):
"""Raised on Process.wait(timeout) if timeout expires and process
is still alive.
"""

__module__ = 'psutil'

def __init__(self, seconds, pid=None, name=None):
1 change: 1 addition & 0 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
@@ -1191,6 +1191,7 @@ class RootFsDeviceFinder:
https://bootlin.com/blog/find-root-device/
https://www.systutorials.com/how-to-find-the-disk-where-root-is-on-in-bash-on-linux/
"""

__slots__ = ['major', 'minor']

def __init__(self):
3 changes: 3 additions & 0 deletions psutil/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1083,6 +1083,7 @@ class TestLeaks(psutil.tests.TestMemoryLeak):
def test_fun(self):
self.execute(some_function)
"""

# Configurable class attrs.
times = 200
warmup_times = 10
@@ -1315,6 +1316,7 @@ class process_namespace:
>>> for fun, name in ns.iter(ns.getters):
... fun()
"""

utils = [
('cpu_percent', (), {}),
('memory_percent', (), {}),
@@ -1451,6 +1453,7 @@ class system_namespace:
>>> for fun, name in ns.iter(ns.getters):
... fun()
"""

getters = [
('boot_time', (), {}),
('cpu_count', (), {'logical': False}),
1 change: 1 addition & 0 deletions psutil/tests/runner.py
Original file line number Diff line number Diff line change
@@ -149,6 +149,7 @@ class ColouredTextRunner(unittest.TextTestRunner):
A coloured text runner which also prints failed tests on KeyboardInterrupt
and save failed tests in a file so that they can be re-run.
"""

resultclass = ColouredResult if USE_COLORS else unittest.TextTestResult

def __init__(self, *args, **kwargs):
1 change: 1 addition & 0 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
@@ -1462,6 +1462,7 @@ class LimitedUserTestCase(TestProcess):
Executed only on UNIX and only if the user who run the test script
is root.
"""

# the uid/gid the test suite runs under
if hasattr(os, 'getuid'):
PROCESS_UID = os.getuid()
2 changes: 2 additions & 0 deletions psutil/tests/test_unicode.py
Original file line number Diff line number Diff line change
@@ -309,6 +309,7 @@ def normpath(p):
@unittest.skipIf(CI_TESTING, "unreliable on CI")
class TestFSAPIsWithInvalidPath(TestFSAPIs):
"""Test FS APIs with a funky, invalid path name."""

funky_suffix = INVALID_UNICODE_SUFFIX

def expect_exact_path_match(self):
@@ -323,6 +324,7 @@ def expect_exact_path_match(self):

class TestNonFSAPIS(BaseUnicodeTest):
"""Unicode tests for non fs-related APIs."""

funky_suffix = UNICODE_SUFFIX if PY3 else 'è'

@unittest.skipIf(not HAS_ENVIRON, "not supported")
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ target-version = "py37"
line-length = 79
select = [
"ALL", # to get a list of all values: `python3 -m ruff linter`
"D204", # [*] 1 blank line required after class docstring (pydocstyle)
]
ignore = [
"A", # flake8-builtins