Skip to content

Commit 1fe373b

Browse files
committed
fixes to pass pylint docstring items
-fix formatting issues -any missed docstrings
1 parent c9a6e38 commit 1fe373b

14 files changed

Lines changed: 39 additions & 33 deletions

end-to-end-tests/tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Test end-to-end functionality for sysrsync."""
12
import inspect
23
import os
34
import sys
@@ -11,7 +12,10 @@
1112

1213

1314
class TestE2E(unittest.TestCase):
15+
"""Test end-to-end functionality."""
16+
1417
def test_send_file(self):
18+
"""Test sending a file from local to remote."""
1519
sysrsync.run(source="end-to-end-tests/test-cases/test_file",
1620
destination="/tmp/target_test_file",
1721
destination_ssh="test@openssh-server",
@@ -20,6 +24,7 @@ def test_send_file(self):
2024
strict_host_key_checking=False)
2125

2226
def test_send_file_with_spaces(self):
27+
"""Test sending a file with spaces from local to remote."""
2328
sysrsync.run(source="end-to-end-tests/test-cases/file with spaces",
2429
destination="/tmp/target_test_file",
2530
destination_ssh="test@openssh-server",

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Setup script for sysrsync."""
12
import setuptools
23
import toml
34

sysrsync/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
"""sysrsync: A Python wrapper for rsync."""
12
from .command_maker import *
23
from .runner import run

sysrsync/command_maker.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Generates the rsync command."""
12
import os
23
import os.path
34
from typing import Iterable, List, Optional
@@ -17,9 +18,7 @@ def get_rsync_command(source: str,
1718
private_key: Optional[str] = None,
1819
rsh_port: Optional[int] = None,
1920
strict_host_key_checking: Optional[bool] = None) -> List[str]:
20-
"""
21-
Generates the rsync command with the specified options for synchronizing files and
22-
directories.
21+
"""Generate rsync command with the specified options for synchronizing files and directories.
2322
2423
Args:
2524
source (str): The source directory or file path.

sysrsync/exceptions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Exceptions for sysrsync."""
12
class RemotesError(Exception):
23
"""
34
Exception raised when both the source and destination are remote.
@@ -8,14 +9,14 @@ class RemotesError(Exception):
89
"""
910

1011
def __init__(self):
12+
"""Initialize the RemotesError exception."""
1113
message = 'source and destination cannot both be remote'
1214
super().__init__(message)
1315

1416

1517
class RsyncError(Exception):
16-
"""
17-
Exception raised for errors related to rsync operations.
18-
"""
18+
"""Exception raised for errors related to rsync operations."""
19+
1920
pass
2021

2122

@@ -31,5 +32,6 @@ class PrivateKeyError(Exception):
3132
"""
3233

3334
def __init__(self, key_file):
35+
"""Initialize the PrivateKeyError exception."""
3436
message = f'Private Key File "{key_file}" does not exist'
3537
super().__init__(message)

sysrsync/helpers/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Helpers for sysrsync."""

sysrsync/helpers/directories.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
"""Directory helper functions for sysrsync."""
12
from typing import Tuple, Optional
23

34

45
def get_directory_with_ssh(directory: str, ssh: Optional[str]) -> str:
56
"""
6-
Returns the directory path with SSH prefix if SSH is provided.
7+
Return the directory path with SSH prefix if SSH is provided.
78
89
Args:
910
directory (str): The directory path.
@@ -46,7 +47,7 @@ def sanitize_trailing_slash(source_dir, target_dir, sync_sourcedir_contents=True
4647

4748
def strip_trailing_slash(directory: str) -> str:
4849
"""
49-
Strips the trailing slash from the directory path if it exists.
50+
Strip the trailing slash from the directory path if it exists.
5051
5152
Args:
5253
directory (str): The directory path.
@@ -55,14 +56,12 @@ def strip_trailing_slash(directory: str) -> str:
5556
str: The directory path without the trailing slash, if present. Otherwise,
5657
returns the directory path as is.
5758
"""
58-
5959
return (directory[:-1]
6060
if directory.endswith('/')
6161
else directory)
6262

6363
def add_trailing_slash(directory: str) -> str:
64-
"""
65-
Adds a trailing slash to the directory path if it doesn't already have one.
64+
"""Add a trailing slash to the directory path if it doesn't already have one.
6665
6766
Args:
6867
directory (str): The directory path.
@@ -71,7 +70,6 @@ def add_trailing_slash(directory: str) -> str:
7170
str: The directory path with a trailing slash, if it doesn't already have one.
7271
Otherwise, returns the directory path as is.
7372
"""
74-
7573
return (directory
7674
if directory.endswith('/')
7775
else f'{directory}/')

sysrsync/helpers/iterators.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Iterator helper functions for sysrsync."""
12
import collections
23

34
if 'Iterable' in dir(collections):
@@ -11,9 +12,6 @@
1112

1213

1314
def flatten(input_iter: Iterable[Any]) -> List[Any]:
14-
list_of_lists = (element if isinstance(element, Iterable)
15-
else [element]
16-
for element in input_iter)
1715
"""
1816
Flattens an iterable by converting nested iterables into a single flat list.
1917
@@ -24,5 +22,8 @@ def flatten(input_iter: Iterable[Any]) -> List[Any]:
2422
List[Any]: A list containing all the elements from the input iterable, with
2523
nested iterables flattened.
2624
"""
25+
list_of_lists = (element if isinstance(element, Iterable)
26+
else [element]
27+
for element in input_iter)
2728

2829
return reduce(iconcat, list_of_lists, [])

sysrsync/helpers/rsync.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Generates rsync arguments based on the provided options for sysrsync."""
12
import os
23
from pathlib import Path
34
from typing import Iterable, List, Optional
@@ -7,8 +8,7 @@
78

89

910
def get_exclusions(exclusions: Iterable[str]) -> Iterable[str]:
10-
"""
11-
Generates a list of rsync exclusion arguments based on the provided exclusions.
11+
"""Generate a list of rsync exclusion arguments based on the provided exclusions.
1212
1313
Args:
1414
exclusions (Iterable[str]): The exclusions to be used for generating the rsync
@@ -24,9 +24,7 @@ def get_exclusions(exclusions: Iterable[str]) -> Iterable[str]:
2424

2525

2626
def get_rsh_command(private_key: Optional[str] = None, port: Optional[int] = None, strict_host_key_checking: Optional[bool] = None):
27-
28-
"""
29-
Generates the rsync remote shell (rsh) command with the specified options.
27+
"""Generate rsync remote shell (rsh) command with the specified options.
3028
3129
Args:
3230
private_key (Optional[str], optional): The path to the private key file.

sysrsync/runner.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Runs the rsync command with the specified options."""
12
import os
23
import subprocess
34

@@ -6,8 +7,7 @@
67

78

89
def run(cwd=os.getcwd(), strict=True, verbose=False, **kwargs):
9-
"""
10-
Runs the rsync command with the specified options.
10+
"""Run the rsync command with the specified options.
1111
1212
Args:
1313
cwd (str, optional): The current working directory. Defaults to the current
@@ -39,8 +39,7 @@ def run(cwd=os.getcwd(), strict=True, verbose=False, **kwargs):
3939

4040

4141
def _check_return_code(return_code: int, action: str):
42-
"""
43-
Checks the return code of an action and raises an exception if it is non-zero.
42+
"""Check the return code of an action and raises an exception if it is non-zero.
4443
4544
Args:
4645
return_code (int): The return code of the action.

0 commit comments

Comments
 (0)