diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 369986db6..5844aedbb 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -19,7 +19,7 @@ jobs: with: python-version-file: .github/python-version.txt - run: pip install -e .[dev] - - run: ruff --fix-only . + - run: ruff check --fix-only . - run: ruff format . - run: web/gen/all diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py index 3dbc215c5..c77b3945f 100644 --- a/mitmproxy/optmanager.py +++ b/mitmproxy/optmanager.py @@ -267,7 +267,7 @@ class OptManager: if attr not in self._options: raise KeyError("No such option: %s" % attr) o = self._options[attr] - if o.typespec != bool: + if o.typespec is not bool: raise ValueError("Toggler can only be used with boolean options") def toggle(): @@ -379,7 +379,7 @@ class OptManager: optstr = None if o.typespec in (str, Optional[str]): - if o.typespec == str and optstr is None: + if o.typespec is str and optstr is None: raise exceptions.OptionsError(f"Option is required: {o.name}") return optstr elif o.typespec in (int, Optional[int]): @@ -388,11 +388,11 @@ class OptManager: return int(optstr) except ValueError: raise exceptions.OptionsError(f"Not an integer: {optstr}") - elif o.typespec == int: + elif o.typespec is int: raise exceptions.OptionsError(f"Option is required: {o.name}") else: return None - elif o.typespec == bool: + elif o.typespec is bool: if optstr == "toggle": return not o.current() if not optstr or optstr == "true": @@ -424,7 +424,7 @@ class OptManager: flags = mkf(optname, short) - if o.typespec == bool: + if o.typespec is bool: g = parser.add_mutually_exclusive_group(required=False) onf = mkf(optname, None) offf = mkf("no-" + optname, None) diff --git a/mitmproxy/tools/console/options.py b/mitmproxy/tools/console/options.py index 8aca078ba..5b70fba11 100644 --- a/mitmproxy/tools/console/options.py +++ b/mitmproxy/tools/console/options.py @@ -38,7 +38,7 @@ class OptionItem(urwid.WidgetWrap): def get_widget(self): val = self.opt.current() - if self.opt.typespec == bool: + if self.opt.typespec is bool: displayval = "true" if val else "false" elif not val: displayval = "" @@ -190,7 +190,7 @@ class OptionsList(urwid.ListBox): self.walker._modified() elif key == "m_select": foc, idx = self.get_focus() - if foc.opt.typespec == bool: + if foc.opt.typespec is bool: self.master.options.toggler(foc.opt.name)() # Bust the focus widget cache self.set_focus(self.walker.index) diff --git a/pyproject.toml b/pyproject.toml index e8fc163f7..c86752863 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ dev = [ "wheel>=0.36.2,<=0.43", "build>=0.10.0,<=1.2.1", "mypy<=1.10.1,>=1.10.1", - "ruff>=0.4.1,<=0.4.7", + "ruff<=0.5.0,>=0.5.0", "types-certifi>=2021.10.8.3,<=2021.10.8.3", "types-Flask>=1.1.6,<=1.1.6", "types-Werkzeug>=1.0.9,<=1.0.9", @@ -299,7 +299,7 @@ uv_resolution = lowest-direct [testenv:lint] commands = - ruff . + ruff check . [testenv:filename_matching] deps = diff --git a/web/gen/options_js.py b/web/gen/options_js.py index d9ea7c66c..2bd1ddbc3 100755 --- a/web/gen/options_js.py +++ b/web/gen/options_js.py @@ -17,11 +17,11 @@ filename = here / "../src/js/ducks/_options_gen.ts" def _ts_type(t): - if t == bool: + if t is bool: return "boolean" - if t == str: + if t is str: return "string" - if t == int: + if t is int: return "number" if t == Sequence[str]: return "string[]"