diff --git a/ops/framework.py b/ops/framework.py index 06dc5c55c..a7c4ff666 100644 --- a/ops/framework.py +++ b/ops/framework.py @@ -716,7 +716,7 @@ def register_type( parent_path = parent.path kind_: str = kind or cls.handle_kind - self._type_registry[(parent_path, kind_)] = cls + self._type_registry[parent_path, kind_] = cls self._type_known.add(cls) def save_snapshot(self, value: Union['StoredStateData', 'EventBase']): diff --git a/ops/pebble.py b/ops/pebble.py index 614451944..6301fa503 100644 --- a/ops/pebble.py +++ b/ops/pebble.py @@ -3216,7 +3216,7 @@ def feed(self, data: bytes): self._parser.feed(data) def _prepare_tempfile(self, filename: str): - tf = tempfile.NamedTemporaryFile(delete=False) + tf = tempfile.NamedTemporaryFile(delete=False) # noqa: SIM115 self._files[filename] = tf # type: ignore # we have a custom protocol for it self.current_filename = filename diff --git a/pyproject.toml b/pyproject.toml index 024bb943e..44040ca5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -171,10 +171,10 @@ ignore = [ "RUF015", # Mutable class attributes should be annotated with `typing.ClassVar` "RUF012", - # Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead - "RUF025", # Unnecessary `tuple` call (rewrite as a literal) "C408", + # Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead + "C420", ] [tool.ruff.lint.pyupgrade] diff --git a/test/test_main.py b/test/test_main.py index 6aea9eed4..2ce616268 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -1231,7 +1231,7 @@ def test_hook_and_dispatch_with_failing_hook( request: pytest.FixtureRequest, fake_script: FakeScript, ): - self.stdout = self.stderr = tempfile.TemporaryFile() + self.stdout = self.stderr = tempfile.TemporaryFile() # noqa: SIM115 request.addfinalizer(self.stdout.close) fake_script_hooks = FakeScript(request, self.hooks_dir) @@ -1383,7 +1383,7 @@ def _call_event( @pytest.mark.usefixtures('setup_charm') def test_crash_action(self, request: pytest.FixtureRequest, fake_script: FakeScript): self._prepare_actions() - self.stderr = tempfile.TemporaryFile('w+t') + self.stderr = tempfile.TemporaryFile('w+t') # noqa: SIM115 request.addfinalizer(self.stderr.close) fake_script.write('action-get', "echo '{}'") with pytest.raises(subprocess.CalledProcessError): diff --git a/test/test_model.py b/test/test_model.py index 7eb2ffafe..01df174da 100644 --- a/test/test_model.py +++ b/test/test_model.py @@ -2808,7 +2808,7 @@ def test_relation_set_juju_version_quirks( version: str, ): # on 2.7.0+, things proceed as expected - t = tempfile.NamedTemporaryFile() + t = tempfile.NamedTemporaryFile() # noqa: SIM115 try: fake_script.write( 'relation-set', diff --git a/test/test_pebble.py b/test/test_pebble.py index 082aeaf8b..602fe3134 100644 --- a/test/test_pebble.py +++ b/test/test_pebble.py @@ -3691,9 +3691,9 @@ def test_wait_passed_output_bad_command( assert io_ws.sends == [] def test_wait_file_io(self, client: MockClient): - fin = tempfile.TemporaryFile(mode='w+', encoding='utf-8') - out = tempfile.TemporaryFile(mode='w+', encoding='utf-8') - err = tempfile.TemporaryFile(mode='w+', encoding='utf-8') + fin = tempfile.TemporaryFile(mode='w+', encoding='utf-8') # noqa: SIM115 + out = tempfile.TemporaryFile(mode='w+', encoding='utf-8') # noqa: SIM115 + err = tempfile.TemporaryFile(mode='w+', encoding='utf-8') # noqa: SIM115 try: fin.write('foo\n') fin.seek(0) diff --git a/test/test_storage.py b/test/test_storage.py index 2df43df1d..6c5a842a9 100644 --- a/test/test_storage.py +++ b/test/test_storage.py @@ -441,7 +441,7 @@ def test_is_available(self, fake_script: FakeScript): assert fake_script.calls(clear=True) == [] def test_set_encodes_args(self, fake_script: FakeScript): - t = tempfile.NamedTemporaryFile() + t = tempfile.NamedTemporaryFile() # noqa: SIM115 try: fake_script.write( 'state-set', @@ -478,7 +478,7 @@ def test_get(self, fake_script: FakeScript): ] def test_set_and_get_complex_value(self, fake_script: FakeScript): - t = tempfile.NamedTemporaryFile() + t = tempfile.NamedTemporaryFile() # noqa: SIM115 try: fake_script.write( 'state-set', diff --git a/tox.ini b/tox.ini index 75df7a569..947454c86 100644 --- a/tox.ini +++ b/tox.ini @@ -60,14 +60,14 @@ commands = [testenv:fmt] description = Apply coding style standards to code deps = - ruff==0.4.5 + ruff==0.7.0 commands = ruff format --preview [testenv:lint] description = Check code against coding style standards deps = - ruff==0.4.5 + ruff==0.7.0 codespell==2.3.0 commands = ruff check --preview