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

Enable more ruff lints #7005

Merged
merged 7 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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 edb/common/parametric.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def _init_parametric_base(cls) -> None:
assert len(args) == 1

arg = args[0]
if typing_inspect.get_origin(arg) != type:
if typing_inspect.get_origin(arg) is not type:
continue

arg_args = typing_inspect.get_args(arg)
Expand Down
2 changes: 1 addition & 1 deletion edb/edgeql/compiler/schemactx.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def concretify(
return get_union_type(ts, ctx=ctx)
if els := t.get_intersection_of(ctx.env.schema):
ts = [concretify(e, ctx=ctx) for e in els.objects(ctx.env.schema)]
return get_intersection_type(ts , ctx=ctx)
return get_intersection_type(ts, ctx=ctx)
return t


Expand Down
2 changes: 1 addition & 1 deletion edb/edgeql/compiler/setgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1944,7 +1944,7 @@ def should_materialize_type(


def get_global_param(
glob: s_globals.Global, * , ctx: context.ContextLevel) -> irast.Global:
glob: s_globals.Global, *, ctx: context.ContextLevel) -> irast.Global:
name = glob.get_name(ctx.env.schema)

if name not in ctx.env.query_globals:
Expand Down
2 changes: 1 addition & 1 deletion edb/edgeql/parser/grammar/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def reduce_Insert(self, *kids):
shape = []

if isinstance(subj_path, qlast.Path) and \
len(subj_path.steps) == 1 and \
len(subj_path.steps) == 1 and \
isinstance(subj_path.steps[0], qlast.ObjectRef):
objtype = subj_path.steps[0]
elif isinstance(subj_path, qlast.IfElse):
Expand Down
4 changes: 2 additions & 2 deletions edb/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,15 @@ def iter_environ():
except KeyError:
continue
choices = setting.enum_values
if setting.type == bool:
if setting.type is bool:
choices = ['true', 'false']
env_value = env_value.lower()
if choices is not None and env_value not in choices:
raise server.StartupError(
f"Environment variable {env_name!r} can only be one of: " +
", ".join(choices)
)
if setting.type == bool:
if setting.type is bool:
env_value = env_value == 'true'
elif not issubclass(setting.type, statypes.ScalarType): # type: ignore
env_value = setting.type(env_value) # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion edb/server/protocol/auth_ext/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def render_password_reset_email(
</div>
</td>
</tr>
""" # noqa: E501
""" # noqa: E501
html_msg = mime_text.MIMEText(
render.base_default_email(
app_name=app_name,
Expand Down
4 changes: 2 additions & 2 deletions edb/server/protocol/auth_ext/ui/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def base_default_email(
</table>
</div>
<!--[if mso | IE]></td></tr></table><table align="center" border="0" cellpadding="0" cellspacing="0" class="" style="width:600px;" width="600" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
""" if logo_url else "" # noqa: E501
""" if logo_url else "" # noqa: E501

return f"""
<!doctype html>
Expand Down Expand Up @@ -601,4 +601,4 @@ def base_default_email(
</div>
</body>
</html>
""" # noqa: E501
""" # noqa: E501
4 changes: 2 additions & 2 deletions edb/tools/profiling/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def module(self) -> str:
result = self.func[0]
edgedb = str(EDGEDB_DIR) + os.sep
if result.startswith(edgedb):
return result[len(edgedb) :]
return result[len(edgedb):]

parts = []
maybe_stdlib = False
Expand Down Expand Up @@ -862,7 +862,7 @@ def build_svg_blocks_by_memory(
color=color,
level=level,
tooltip=(
f"{caller.size / 1024 :.2f} KiB / {caller.blocks}"
f"{caller.size / 1024:.2f} KiB / {caller.blocks}"
f" blocks \N{RIGHTWARDS DOUBLE ARROW} {line}"
),
w=caller.size,
Expand Down
2 changes: 1 addition & 1 deletion edb/tools/test/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def _dataclass_from_dict(cls: typing.Type | None, data: typing.Any):
if not cls:
return data

if typing_inspect.get_origin(cls) == list:
if typing_inspect.get_origin(cls) is list:
args = typing_inspect.get_args(cls)
return [_dataclass_from_dict(args[0], e) for e in data]

Expand Down
23 changes: 15 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,22 @@ ignore_errors = true
# CACHE-TAG: 1

[tool.ruff]
lint.select = ["E", "F", "B"]
lint.select = ["E", "F", "W", "B"]
lint.ignore = [
"F541",
"B008",
"B904",
"B905",
"B019",
"E731",
"E741",
"F541", # f-string without any placeholders
"B008", # Do not perform function call {name} in argument defaults;
# instead, perform the call within the function, or read the
# default from a module-level singleton variable
"B904", # Within an except clause, raise exceptions with raise ... from err
# or raise ... from None to distinguish them from errors in
# exception handling
"B905", # zip() without an explicit strict= parameter
"B019", # Use of functools.lru_cache or functools.cache on methods can lead
# to memory leaks
"E731", # Do not assign a lambda expression, use a def
"E741", # Ambiguous variable name: l or i or I
"E252", # Missing whitespace around parameter equals
"F841", # unused variable
]
line-length = 80
indent-width = 4
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dump_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def _ensure_schema_data_integrity(self, include_secrets):
'''
select ext::_conf::get_top_secret()
''',
['secret'] if include_secrets else [] ,
['secret'] if include_secrets else [],
)

# We took a version snapshot for 4.0, but then needed to
Expand Down
2 changes: 1 addition & 1 deletion tests/test_edgeql_data_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6096,7 +6096,7 @@ async def test_edgeql_migration_rename_02(self):

await self.interact([
"did you rename property 'asdf' of object type 'test::Foo' to "
"'womp'?" ,
"'womp'?",

"did you create annotation 'std::title' of property 'womp'?",
])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_edgeql_ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9865,7 +9865,7 @@ async def test_edgeql_ddl_alias_11(self):
async def test_edgeql_ddl_alias_12(self):
await self.con.execute(
r"""
create alias X := 1;
create alias X := 1;
create type Y;
create global Z -> int64;
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_edgeql_for.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ async def test_edgeql_for_in_computable_02c(self):
} FILTER .name = 'Alice'
""",
[{
"select_deck" : [
{"name" : "Imp", "count" : 1},
{"name" : "Dragon", "count" : 2},
"select_deck": [
{"name": "Imp", "count": 1},
{"name": "Dragon", "count": 2},
],
}],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_http_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_http_auth_scram_valid(self):
(msize,) = uint32_unpack(content[1:5])
msg = protocol.ServerMessage.parse(mtype, content[5 : msize + 1])
msgs.append(msg)
content = content[msize + 1 :]
content = content[msize + 1:]
self.assertIsInstance(msgs[0], protocol.CommandDataDescription)
self.assertIsInstance(msgs[1], protocol.Data)
self.assertEqual(bytes(msgs[1].data[0].data), b"42")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pgext.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def deserialize(data):
if DEBUG:
print(PID, "< ", rv)
yield rv
buf = buf[msg_size + 1 :]
buf = buf[msg_size + 1:]


class PgProtocol(asyncio.Protocol):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4454,7 +4454,7 @@ def test_schema_migrations_equivalence_22(self):
produces DDL, but the DDL doesn't really make any sense. We
are going to probably need to add DDL syntax to accomplish
this.

Before we do that, we could just improve the error:
cannot produce migration because of a dependency cycle:
create alias 'default::Base' depends on
Expand Down