diff --git a/.evergreen/scripts/resync_all_specs.py b/.evergreen/scripts/resync_all_specs.py index 52c276b8b8..a5c09191a7 100644 --- a/.evergreen/scripts/resync_all_specs.py +++ b/.evergreen/scripts/resync_all_specs.py @@ -17,7 +17,7 @@ def resync_specs(directory: pathlib.Path, errored: dict[str, str]) -> None: if not spec.is_dir(): continue - if spec.name in ["asynchronous"]: + if spec.name == "asynchronous": continue try: subprocess.run( # noqa: S603 diff --git a/pymongo/common.py b/pymongo/common.py index d160e28235..53815fd7dd 100644 --- a/pymongo/common.py +++ b/pymongo/common.py @@ -462,7 +462,7 @@ def validate_auth_mechanism_properties(option: str, value: Any) -> dict[str, boo props[key] = prop_value elif isinstance(prop_value, bool): props[key] = str(prop_value).lower() - elif key in ["ALLOWED_HOSTS"] and isinstance(prop_value, list): + elif key == "ALLOWED_HOSTS" and isinstance(prop_value, list): props[key] = prop_value elif key in ["OIDC_CALLBACK", "OIDC_HUMAN_CALLBACK"]: from pymongo.auth_oidc_shared import OIDCCallback diff --git a/pymongo/errors.py b/pymongo/errors.py index 70d436923c..13762a172e 100644 --- a/pymongo/errors.py +++ b/pymongo/errors.py @@ -222,7 +222,7 @@ def details(self) -> Mapping[str, Any] | None: @property def timeout(self) -> bool: - return self.__code in (50,) + return self.__code == 50 @property def _base_backoff_ms(self) -> float | None: diff --git a/pyproject.toml b/pyproject.toml index a7c4cdce84..4ca15dc88b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -210,6 +210,7 @@ extend-select = [ "ASYNC", # flake8-async "TC", # flake8-type-checking "PERF", # perflint + "FURB", # refurb # Non-design pylint rules. "PLR0124", # pylint: comparison of a name with itself "PLR0133", # pylint: comparison between two constants diff --git a/test/asynchronous/test_transactions.py b/test/asynchronous/test_transactions.py index 64b58ba5e6..0c277fb0b3 100644 --- a/test/asynchronous/test_transactions.py +++ b/test/asynchronous/test_transactions.py @@ -420,7 +420,7 @@ async def asyncSetUp(self) -> None: self.mongos_clients.append(await self.async_single_client("{}:{}".format(*address))) async def set_fail_point(self, command_args): - clients = self.mongos_clients if self.mongos_clients else [self.client] + clients = self.mongos_clients or [self.client] for client in clients: await self.configure_fail_point(client, command_args) diff --git a/test/asynchronous/unified_format.py b/test/asynchronous/unified_format.py index 6f320f6105..868711f039 100644 --- a/test/asynchronous/unified_format.py +++ b/test/asynchronous/unified_format.py @@ -878,7 +878,7 @@ async def _databaseOperation_assertCollectionExists(self, target, **kwargs): async def kill_all_sessions(self): if getattr(self, "client", None) is None: return - clients = self.mongos_clients if self.mongos_clients else [self.client] + clients = self.mongos_clients or [self.client] for client in clients: try: await client.admin.command("killAllSessions", []) diff --git a/test/test_bson_binary_vector.py b/test/test_bson_binary_vector.py index 533d8960bd..59083fa1f8 100644 --- a/test/test_bson_binary_vector.py +++ b/test/test_bson_binary_vector.py @@ -72,7 +72,7 @@ def run_test(self): self.assertEqual( vector_obs.dtype, BinaryVectorDtype[dtype_alias_exp], description ) - if dtype_exp in [BinaryVectorDtype.FLOAT32]: + if dtype_exp == BinaryVectorDtype.FLOAT32: [ self.assertAlmostEqual(vector_obs.data[i], vector_exp[i], delta=1e-5) for i in range(len(vector_exp)) diff --git a/test/test_transactions.py b/test/test_transactions.py index dfaeebf897..cd2b7df900 100644 --- a/test/test_transactions.py +++ b/test/test_transactions.py @@ -412,7 +412,7 @@ def setUp(self) -> None: self.mongos_clients.append(self.single_client("{}:{}".format(*address))) def set_fail_point(self, command_args): - clients = self.mongos_clients if self.mongos_clients else [self.client] + clients = self.mongos_clients or [self.client] for client in clients: self.configure_fail_point(client, command_args) diff --git a/test/unified_format.py b/test/unified_format.py index 313b7eda20..6c05eb74b4 100644 --- a/test/unified_format.py +++ b/test/unified_format.py @@ -875,7 +875,7 @@ def _databaseOperation_assertCollectionExists(self, target, **kwargs): def kill_all_sessions(self): if getattr(self, "client", None) is None: return - clients = self.mongos_clients if self.mongos_clients else [self.client] + clients = self.mongos_clients or [self.client] for client in clients: try: client.admin.command("killAllSessions", [])