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

ci(framework:skip) Update PyLint to 3.3.1 #3990

Merged
merged 31 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9ba05d1
ci(framework:skip) Update PyLint and process stubs
charlesbvll Aug 11, 2024
afba01e
Fix pytint errors
charlesbvll Aug 11, 2024
8d47140
Refactor vce
charlesbvll Aug 11, 2024
542ee24
Fix formatting
charlesbvll Aug 11, 2024
bf2c842
Merge branch 'main' into update-pylint
charlesbvll Aug 11, 2024
dc8b83c
Fix arg
charlesbvll Aug 11, 2024
aa69c2e
Fix tests
charlesbvll Aug 11, 2024
b219df0
Merge branch 'main' into update-pylint
tanertopal Aug 13, 2024
66f0b92
Merge branch 'main' into update-pylint
charlesbvll Sep 9, 2024
d10b598
Fix unused variable
charlesbvll Sep 9, 2024
dff25a0
Update pylint
charlesbvll Sep 9, 2024
6d7531b
Merge branch 'main' into update-pylint
charlesbvll Sep 13, 2024
4174233
Merge branch 'main' into update-pylint
charlesbvll Sep 23, 2024
565625d
Use assertions instead of conditions
charlesbvll Sep 23, 2024
c88ce03
Merge branch 'main' into update-pylint
charlesbvll Sep 23, 2024
96f753a
Merge branch 'main' into update-pylint
danieljanes Sep 27, 2024
5ad958d
Merge branch 'main' of https://github.com/adap/flower into update-pylint
charlesbvll Sep 28, 2024
decf065
Fix assignement error
charlesbvll Sep 28, 2024
5235d9f
merge w/ main; adjusted driver_client_proxy_tests.py
jafermarq Oct 9, 2024
9b18658
Merge branch 'main' into update-pylint
charlesbvll Oct 10, 2024
7e570cc
Fix error
charlesbvll Oct 10, 2024
9ad077b
Fix unbound variables
charlesbvll Oct 10, 2024
5d80792
Merge branch 'main' into update-pylint
charlesbvll Oct 10, 2024
d32d29a
Fix unbound
charlesbvll Oct 10, 2024
ac7736a
Merge branch 'update-pylint' of https://github.com/adap/flower into u…
charlesbvll Oct 10, 2024
7e66600
Merge branch 'main' into update-pylint
danieljanes Oct 10, 2024
0f632fd
fix pylint error
panh99 Oct 10, 2024
e249806
Update pylint to latest
charlesbvll Oct 10, 2024
a5ff98e
Merge branch 'main' into update-pylint
danieljanes Oct 11, 2024
90f64f9
Ignore too-many-positional-arguments errors
charlesbvll Oct 11, 2024
52952af
Shorten lines
charlesbvll Oct 11, 2024
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ black = { version = "==24.2.0", extras = ["jupyter"] }
taplo = "==0.9.3"
docformatter = "==1.7.5"
mypy = "==1.8.0"
pylint = "==3.0.3"
pylint = "==3.3.1"
flake8 = "==5.0.4"
parameterized = "==0.9.0"
pytest = "==7.4.4"
Expand Down
9 changes: 4 additions & 5 deletions src/py/flwr/client/clientapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,10 @@ def run_clientapp( # pylint: disable=R0914
)

try:
if fab:
# Load ClientApp
client_app: ClientApp = load_client_app_fn(
run.fab_id, run.fab_version, fab.hash_str
)
# Load ClientApp
client_app: ClientApp = load_client_app_fn(
run.fab_id, run.fab_version, fab.hash_str if fab else ""
)
danieljanes marked this conversation as resolved.
Show resolved Hide resolved

# Execute ClientApp
reply_message = client_app(message=message, context=context)
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/client/grpc_adapter_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


@contextmanager
def grpc_adapter( # pylint: disable=R0913
def grpc_adapter( # pylint: disable=R0913,too-many-positional-arguments
server_address: str,
insecure: bool,
retry_invoker: RetryInvoker,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/client/grpc_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def on_channel_state_change(channel_connectivity: str) -> None:


@contextmanager
def grpc_connection( # pylint: disable=R0913, R0915
def grpc_connection( # pylint: disable=R0913,R0915,too-many-positional-arguments
server_address: str,
insecure: bool,
retry_invoker: RetryInvoker, # pylint: disable=unused-argument
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/client/grpc_rere_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def on_channel_state_change(channel_connectivity: str) -> None:


@contextmanager
def grpc_request_response( # pylint: disable=R0913, R0914, R0915
def grpc_request_response( # pylint: disable=R0913,R0914,R0915,R0917
server_address: str,
insecure: bool,
retry_invoker: RetryInvoker,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/client/node_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(
self.node_config = node_config
self.run_infos: dict[int, RunInfo] = {}

# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,too-many-positional-arguments
def register_context(
self,
run_id: int,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/client/rest_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@


@contextmanager
def http_request_response( # pylint: disable=,R0913, R0914, R0915
def http_request_response( # pylint: disable=R0913,R0914,R0915,R0917
server_address: str,
insecure: bool, # pylint: disable=unused-argument
retry_invoker: RetryInvoker,
Expand Down
1 change: 1 addition & 0 deletions src/py/flwr/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def parse_config_args(
# Regular expression to capture key-value pairs with possible quoted values
pattern = re.compile(r"(\S+?)=(\'[^\']*\'|\"[^\"]*\"|\S+)")

flat_overrides = {}
for config_line in config:
if config_line:
# .toml files aren't allowed alongside other configs
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def update_console_handler(
class CustomHTTPHandler(HTTPHandler):
"""Custom HTTPHandler which overrides the mapLogRecords method."""

# pylint: disable=too-many-arguments,bad-option-value,R1725
# pylint: disable=too-many-arguments,bad-option-value,R1725,R0917
def __init__(
self,
identifier: str,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/common/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Metadata: # pylint: disable=too-many-instance-attributes
the receiving end.
"""

def __init__( # pylint: disable=too-many-arguments
def __init__( # pylint: disable=too-many-arguments,too-many-positional-arguments
self,
run_id: int,
message_id: str,
Expand Down
6 changes: 6 additions & 0 deletions src/py/flwr/common/record/configsrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def count_bytes(self) -> int:

def get_var_bytes(value: ConfigsScalar) -> int:
"""Return Bytes of value passed."""
var_bytes = 0
if isinstance(value, bool):
var_bytes = 1
elif isinstance(value, (int, float)):
Expand All @@ -136,6 +137,11 @@ def get_var_bytes(value: ConfigsScalar) -> int:
)
if isinstance(value, (str, bytes)):
var_bytes = len(value)
if var_bytes == 0:
raise ValueError(
"Config values must be either `bool`, `int`, `float`, "
"`str`, or `bytes`"
)
return var_bytes

num_bytes = 0
Expand Down
1 change: 1 addition & 0 deletions src/py/flwr/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ def _run_fleet_api_grpc_adapter(


# pylint: disable=import-outside-toplevel,too-many-arguments
# pylint: disable=too-many-positional-arguments
def _run_fleet_api_rest(
host: str,
port: int,
Expand Down
11 changes: 6 additions & 5 deletions src/py/flwr/server/compat/driver_client_proxy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_evaluate_and_fail(self) -> None:
)
self._common_assertions(ins)

def _create_message_dummy( # pylint: disable=R0913
def _create_message_dummy( # pylint: disable=R0913,too-many-positional-arguments
self,
content: RecordSet,
message_type: str,
Expand Down Expand Up @@ -237,9 +237,9 @@ def _exec_send_and_receive(

def generate_replies(messages: Iterable[Message]) -> Iterable[Message]:
msg = list(messages)[0]
recordset = None
if error_reply:
recordset = None
ret = msg.create_error_reply(ERROR_REPLY)
pass
elif isinstance(res, GetParametersRes):
recordset = compat.getparametersres_to_recordset(res, True)
elif isinstance(res, GetPropertiesRes):
Expand All @@ -248,10 +248,11 @@ def generate_replies(messages: Iterable[Message]) -> Iterable[Message]:
recordset = compat.fitres_to_recordset(res, True)
elif isinstance(res, EvaluateRes):
recordset = compat.evaluateres_to_recordset(res)
else:
raise ValueError(f"Unsupported type: {type(res)}")

if recordset is not None:
ret = msg.create_reply(recordset)
else:
ret = msg.create_error_reply(ERROR_REPLY)

# Reply messages given the push message
return [ret]
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def run(self) -> Run:
"""Run information."""

@abstractmethod
def create_message( # pylint: disable=too-many-arguments
def create_message( # pylint: disable=too-many-arguments,R0917
self,
content: RecordSet,
message_type: str,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/driver/grpc_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _check_message(self, message: Message) -> None:
):
raise ValueError(f"Invalid message: {message}")

def create_message( # pylint: disable=too-many-arguments
def create_message( # pylint: disable=too-many-arguments,R0917
self,
content: RecordSet,
message_type: str,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/driver/inmemory_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def run(self) -> Run:
self._init_run()
return Run(**vars(cast(Run, self._run)))

def create_message( # pylint: disable=too-many-arguments
def create_message( # pylint: disable=too-many-arguments,R0917
self,
content: RecordSet,
message_type: str,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/server_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ServerApp:
>>> print("ServerApp running")
"""

# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,too-many-positional-arguments
def __init__(
self,
server: Optional[Server] = None,
Expand Down
6 changes: 3 additions & 3 deletions src/py/flwr/server/strategy/bulyan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def test_aggregate_fit() -> None:
actual_aggregated, _ = strategy.aggregate_fit(
server_round=1, results=results, failures=[]
)
if actual_aggregated:
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert actual_aggregated
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert (actual == expected[0]).all()
4 changes: 2 additions & 2 deletions src/py/flwr/server/strategy/dp_adaptive_clipping.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class DifferentialPrivacyServerSideAdaptiveClipping(Strategy):
>>> )
"""

# pylint: disable=too-many-arguments,too-many-instance-attributes
# pylint: disable=too-many-arguments,too-many-instance-attributes,too-many-positional-arguments
def __init__(
self,
strategy: Strategy,
Expand Down Expand Up @@ -307,7 +307,7 @@ class DifferentialPrivacyClientSideAdaptiveClipping(Strategy):
>>> )
"""

# pylint: disable=too-many-arguments,too-many-instance-attributes
# pylint: disable=too-many-arguments,too-many-instance-attributes,too-many-positional-arguments
def __init__(
self,
strategy: Strategy,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/strategy/dpfedavg_adaptive.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DPFedAvgAdaptive(DPFedAvgFixed):
This class is deprecated and will be removed in a future release.
"""

# pylint: disable=too-many-arguments,too-many-instance-attributes
# pylint: disable=too-many-arguments,too-many-instance-attributes,too-many-positional-arguments
def __init__(
self,
strategy: Strategy,
Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/strategy/dpfedavg_fixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DPFedAvgFixed(Strategy):
This class is deprecated and will be removed in a future release.
"""

# pylint: disable=too-many-arguments,too-many-instance-attributes
# pylint: disable=too-many-arguments,too-many-instance-attributes,too-many-positional-arguments
def __init__(
self,
strategy: Strategy,
Expand Down
6 changes: 3 additions & 3 deletions src/py/flwr/server/strategy/fedadagrad_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_aggregate_fit() -> None:
actual_aggregated, _ = strategy.aggregate_fit(
server_round=1, results=results, failures=[]
)
if actual_aggregated:
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert actual_aggregated
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert (actual == expected[0]).all()
6 changes: 3 additions & 3 deletions src/py/flwr/server/strategy/fedmedian_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def test_aggregate_fit() -> None:
actual_aggregated, _ = strategy.aggregate_fit(
server_round=1, results=results, failures=[]
)
if actual_aggregated:
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert actual_aggregated
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert (actual == expected[0]).all()
6 changes: 3 additions & 3 deletions src/py/flwr/server/strategy/krum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_aggregate_fit() -> None:
actual_aggregated, _ = strategy.aggregate_fit(
server_round=1, results=results, failures=[]
)
if actual_aggregated:
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert actual_aggregated
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert (actual == expected[0]).all()
6 changes: 3 additions & 3 deletions src/py/flwr/server/strategy/multikrum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_aggregate_fit() -> None:
actual_aggregated, _ = strategy.aggregate_fit(
server_round=1, results=results, failures=[]
)
if actual_aggregated:
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert actual_aggregated
actual_list = parameters_to_ndarrays(actual_aggregated)
actual = actual_list[0]
assert (actual == expected[0]).all()
4 changes: 2 additions & 2 deletions src/py/flwr/server/superlink/fleet/grpc_bidi/grpc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def valid_certificates(certificates: tuple[bytes, bytes, bytes]) -> bool:
return is_valid


def start_grpc_server( # pylint: disable=too-many-arguments
def start_grpc_server( # pylint: disable=too-many-arguments,R0917
client_manager: ClientManager,
server_address: str,
max_concurrent_workers: int = 1000,
Expand Down Expand Up @@ -156,7 +156,7 @@ def start_grpc_server( # pylint: disable=too-many-arguments
return server


def generic_create_grpc_server( # pylint: disable=too-many-arguments
def generic_create_grpc_server( # pylint: disable=too-many-arguments,R0917
servicer_and_add_fn: Union[
tuple[FleetServicer, AddServicerToServerFn],
tuple[GrpcAdapterServicer, AddServicerToServerFn],
Expand Down
13 changes: 8 additions & 5 deletions src/py/flwr/server/superlink/fleet/vce/vce_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def put_taskres_into_state(
pass


# pylint: disable=too-many-positional-arguments
def run_api(
app_fn: Callable[[], ClientApp],
backend_fn: Callable[[], Backend],
Expand Down Expand Up @@ -251,7 +252,7 @@ def run_api(


# pylint: disable=too-many-arguments,unused-argument,too-many-locals,too-many-branches
# pylint: disable=too-many-statements
# pylint: disable=too-many-statements,too-many-positional-arguments
def start_vce(
backend_name: str,
backend_config_json_stream: str,
Expand All @@ -267,6 +268,8 @@ def start_vce(
existing_nodes_mapping: Optional[NodeToPartitionMapping] = None,
) -> None:
"""Start Fleet API with the Simulation Engine."""
nodes_mapping = {}

if client_app_attr is not None and client_app is not None:
raise ValueError(
"Both `client_app_attr` and `client_app` are provided, "
Expand Down Expand Up @@ -340,17 +343,17 @@ def backend_fn() -> Backend:
# Load ClientApp if needed
def _load() -> ClientApp:

if client_app:
return client_app
if client_app_attr:
app = get_load_client_app_fn(
return get_load_client_app_fn(
default_app_ref=client_app_attr,
app_path=app_dir,
flwr_dir=flwr_dir,
multi_app=False,
)(run.fab_id, run.fab_version, run.fab_hash)

if client_app:
app = client_app
return app
raise ValueError("Either `client_app_attr` or `client_app` must be provided")

app_fn = _load

Expand Down
2 changes: 1 addition & 1 deletion src/py/flwr/server/superlink/fleet/vce/vce_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def _autoresolve_app_dir(rel_client_app_dir: str = "backend") -> str:
return str(rel_app_dir.parent / rel_client_app_dir)


# pylint: disable=too-many-arguments
# pylint: disable=too-many-arguments,too-many-positional-arguments
def start_and_shutdown(
backend: str = "ray",
client_app_attr: Optional[str] = None,
Expand Down
12 changes: 6 additions & 6 deletions src/py/flwr/server/superlink/state/state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ def test_task_res_store_and_retrieve_by_task_ins_id(self) -> None:
# Execute
task_res_uuid = state.store_task_res(task_res)

if task_ins_id is not None:
task_res_list = state.get_task_res(task_ids={task_ins_id})
assert task_ins_id
task_res_list = state.get_task_res(task_ids={task_ins_id})

# Assert
retrieved_task_res = task_res_list[0]
Expand Down Expand Up @@ -811,8 +811,8 @@ def test_get_task_res_not_return_expired(self) -> None:

with patch("time.time", side_effect=lambda: task_ins.task.created_at + 6.1):
# Execute
if task_id is not None:
task_res_list = state.get_task_res(task_ids={task_id})
assert task_id is not None
task_res_list = state.get_task_res(task_ids={task_id})

# Assert
assert len(task_res_list) == 0
Expand Down Expand Up @@ -865,8 +865,8 @@ def test_get_task_res_return_if_not_expired(self) -> None:

with patch("time.time", side_effect=lambda: task_ins.task.created_at + 6.1):
# Execute
if task_id is not None:
task_res_list = state.get_task_res(task_ids={task_id})
assert task_id is not None
task_res_list = state.get_task_res(task_ids={task_id})

# Assert
assert len(task_res_list) != 0
Expand Down
Loading