Skip to content

Commit

Permalink
ci(datasets:skip) Update pylint version (#3867)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-narozniak authored Jul 22, 2024
1 parent 7d7b698 commit de33f9b
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion datasets/flwr_datasets/federated_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class FederatedDataset:
>>> )
"""

# pylint: disable=too-many-instance-attributes
# pylint: disable=too-many-instance-attributes, too-many-arguments
def __init__(
self,
*,
Expand Down
14 changes: 6 additions & 8 deletions datasets/flwr_datasets/federated_dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_resplit_dataset_into_one(self) -> None:
if self.test_split is None:
return
dataset = datasets.load_dataset(self.dataset_name)
dataset_length = sum([len(ds) for ds in dataset.values()])
dataset_length = sum(len(ds) for ds in dataset.values())
fds = FederatedDataset(
dataset=self.dataset_name,
partitioners={"train": 100},
Expand Down Expand Up @@ -216,7 +216,7 @@ def resplit(dataset: DatasetDict) -> DatasetDict:
)
full = fds.load_split("full")
dataset = datasets.load_dataset(self.dataset_name)
dataset_length = sum([len(ds) for ds in dataset.values()])
dataset_length = sum(len(ds) for ds in dataset.values())
self.assertEqual(len(full), dataset_length)

def test_use_load_dataset_kwargs(self) -> None:
Expand Down Expand Up @@ -245,7 +245,6 @@ class ShufflingResplittingOnArtificialDatasetTest(unittest.TestCase):
The load_dataset method is mocked and the artificial dataset is returned.
"""

# pylint: disable=no-self-use
def _dummy_setup(self, train_rows: int = 10, test_rows: int = 5) -> DatasetDict:
"""Create a dummy DatasetDict with train, test splits."""
data_train = {
Expand Down Expand Up @@ -436,14 +435,14 @@ def test_if_the_partitions_have_unique_values(self) -> None:
class IncorrectUsageFederatedDatasets(unittest.TestCase):
"""Test incorrect usages in FederatedDatasets."""

def test_no_partitioner_for_split(self) -> None: # pylint: disable=R0201
def test_no_partitioner_for_split(self) -> None:
"""Test using load_partition with missing partitioner."""
dataset_fds = FederatedDataset(dataset="mnist", partitioners={"train": 100})

with pytest.raises(ValueError):
dataset_fds.load_partition(0, "test")

def test_no_split_in_the_dataset(self) -> None: # pylint: disable=R0201
def test_no_split_in_the_dataset(self) -> None:
"""Test using load_partition with non-existent split name."""
dataset_fds = FederatedDataset(
dataset="mnist", partitioners={"non-existent-split": 100}
Expand All @@ -452,15 +451,14 @@ def test_no_split_in_the_dataset(self) -> None: # pylint: disable=R0201
with pytest.raises(ValueError):
dataset_fds.load_partition(0, "non-existent-split")

def test_unsupported_dataset(self) -> None: # pylint: disable=R0201
def test_unsupported_dataset(self) -> None:
"""Test creating FederatedDataset for unsupported dataset."""
with pytest.warns(UserWarning):
FederatedDataset(dataset="food101", partitioners={"train": 100})

def test_cannot_use_the_old_split_names(self) -> None:
"""Test if the initial split names can not be used."""
dataset = datasets.load_dataset("mnist")
sum([len(ds) for ds in dataset.values()])
datasets.load_dataset("mnist")
fds = FederatedDataset(
dataset="mnist",
partitioners={"train": 100},
Expand Down
1 change: 0 additions & 1 deletion datasets/flwr_datasets/metrics/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
# ==============================================================================
"""Tests for metrics utils."""
# pylint: disable=no-self-use


import unittest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ def partition_id_to_natural_id(self) -> Dict[int, str]:
"""
return self._partition_id_to_natural_id

# pylint: disable=R0201
@partition_id_to_natural_id.setter
def partition_id_to_natural_id(self, value: Dict[int, str]) -> None:
raise AttributeError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_load_partition_max_partition_size(
print(num_unique_natural_ids)
_, partitioner = _dummy_setup(num_rows, num_unique_natural_ids)
max_size = max(
[len(partitioner.load_partition(i)) for i in range(num_unique_natural_ids)]
len(partitioner.load_partition(i)) for i in range(num_unique_natural_ids)
)
self.assertEqual(max_size, math.ceil(num_rows / num_unique_natural_ids))

Expand Down
2 changes: 1 addition & 1 deletion datasets/flwr_datasets/partitioner/partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def dataset(self) -> Dataset:
@dataset.setter
def dataset(self, value: Dataset) -> None:
if self._dataset is not None:
raise Exception(
raise ValueError(
"The dataset should be assigned only once to the partitioner."
"This operation might also wipe out the saved references to the "
"created partitions (in case the partitioning scheme needs to create "
Expand Down
2 changes: 1 addition & 1 deletion datasets/flwr_datasets/preprocessor/merger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_nonexistent_split_in_strategy(self) -> None:
):
merger(self.dataset_dict)

def test_duplicate_merge_split_name(self) -> None: # pylint: disable=R0201
def test_duplicate_merge_split_name(self) -> None:
"""Test that the new split names are not the same."""
strategy: Dict[str, Tuple[str, ...]] = {
"new_train": ("train", "valid"),
Expand Down
2 changes: 1 addition & 1 deletion datasets/flwr_datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def _create_division_indices_ranges(
ranges.append(range(start_idx, end_idx))
start_idx = end_idx
else:
TypeError(
raise TypeError(
f"The type of the `division` should be dict, "
f"tuple or list but is {type(division)} instead. "
)
Expand Down
2 changes: 1 addition & 1 deletion datasets/flwr_datasets/visualization/bar_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _plot_bar(
legend_kwargs["loc"] = "outside center right"

if "bbox_to_anchor" not in legend_kwargs:
max_len_label_str = max([len(str(column)) for column in dataframe.columns])
max_len_label_str = max(len(str(column)) for column in dataframe.columns)
shift = min(0.05 + max_len_label_str / 100, 0.15)
legend_kwargs["bbox_to_anchor"] = (1.0 + shift, 0.5)

Expand Down
4 changes: 2 additions & 2 deletions datasets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ isort = "==5.13.2"
black = { version = "==24.2.0", extras = ["jupyter"] }
docformatter = "==1.7.5"
mypy = "==1.4.0"
pylint = "==2.13.9"
pylint = "==3.0.3"
flake8 = "==3.9.2"
parameterized = "==0.9.0"
pytest = "==7.1.2"
Expand All @@ -95,7 +95,7 @@ line-length = 88
target-version = ["py38", "py39", "py310", "py311"]

[tool.pylint."MESSAGES CONTROL"]
disable = "bad-continuation,duplicate-code,too-few-public-methods,useless-import-alias"
disable = "duplicate-code,too-few-public-methods,useless-import-alias"

[tool.pytest.ini_options]
minversion = "6.2"
Expand Down

0 comments on commit de33f9b

Please sign in to comment.