You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not necessarily bad, but assertions are removed when Python is run with optimization requested (compiling to optimised byte code, python -O ... producing *.opt-1.pyc files). This is likely never going to be an issue for Rucio, but I still wanted to open an issue to discuss this.
Additionally, when assert fails, it raises AssertionError. In the context of our usage of assert, I think we could raise more specific exceptions with clearer messages, which might also help from the point of view of debugging.
To do
I would like us to decide on one of these options:
We decide that the current production usage of assert is fine. In this case, we only need to set the linter to ignore S101 (usage of assert) and no other changes will be needed.
We decide that we want to replace our usage of assert with regular condition checking and custom exceptions. In this case, we'd need to make these changes.
❯ ruff check --select S101 ─╯
bin/rucio-admin:1198:5: S101 Use of `assert` detected
bin/rucio-auditor:51:5: S101 Use of `assert` detected
bin/rucio-auditor:58:5: S101 Use of `assert` detected
bin/rucio-auditor:72:5: S101 Use of `assert` detected
bin/rucio-dumper:99:9: S101 Use of `assert` detected
bin/rucio-dumper:117:9: S101 Use of `assert` detected
bin/rucio-dumper:128:13: S101 Use of `assert` detected
lib/rucio/client/lockclient.py:61:9: S101 Use of `assert` detected
lib/rucio/common/dumper/__init__.py:73:9: S101 Use of `assert` detected
lib/rucio/common/dumper/consistency.py:44:13: S101 Use of `assert` detected
lib/rucio/common/dumper/consistency.py:45:13: S101 Use of `assert` detected
lib/rucio/common/dumper/consistency.py:47:13: S101 Use of `assert` detected
lib/rucio/common/dumper/consistency.py:169:5: S101 Use of `assert` detected
lib/rucio/common/dumper/consistency.py:304:5: S101 Use of `assert` detected
lib/rucio/common/dumper/consistency.py:392:5: S101 Use of `assert` detected
lib/rucio/common/dumper/data_models.py:160:13: S101 Use of `assert` detected
lib/rucio/common/dumper/data_models.py:240:9: S101 Use of `assert` detected
lib/rucio/common/dumper/data_models.py:267:9: S101 Use of `assert` detected
lib/rucio/common/dumper/data_models.py:295:13: S101 Use of `assert` detected
lib/rucio/common/utils.py:1910:9: S101 Use of `assert` detected
lib/rucio/common/utils.py:1948:9: S101 Use of `assert` detected
lib/rucio/core/lock.py:83:9: S101 Use of `assert` detected
lib/rucio/core/lock.py:92:9: S101 Use of `assert` detected
lib/rucio/core/oidc.py:100:9: S101 Use of `assert` detected
lib/rucio/daemons/auditor/srmdumps.py:67:9: S101 Use of `assert` detected
lib/rucio/db/sqla/session.py:225:5: S101 Use of `assert` detected
lib/rucio/db/sqla/session.py:261:5: S101 Use of `assert` detected
lib/rucio/db/sqla/session.py:280:5: S101 Use of `assert` detected
lib/rucio/db/sqla/util.py:125:13: S101 Use of `assert` detected
lib/rucio/db/sqla/util.py:309:9: S101 Use of `assert` detected
lib/rucio/transfertool/fts3_plugins.py:125:13: S101 Use of `assert` detected
lib/rucio/web/rest/flaskapi/v1/dids.py:457:13: S101 Use of `assert` detected
Found 32 errors.
The text was updated successfully, but these errors were encountered:
Description
Right now, we are using
assert
in production code, outside tests (see the linter log below).Some usage examples:
rucio/bin/rucio-auditor
Line 58 in bc8fae0
rucio/bin/rucio-dumper
Line 128 in 3397448
rucio/lib/rucio/common/dumper/consistency.py
Lines 44 to 47 in 3397448
rucio/lib/rucio/core/lock.py
Line 83 in 3397448
This is not necessarily bad, but assertions are removed when Python is run with optimization requested (compiling to optimised byte code,
python -O ...
producing*.opt-1.pyc
files). This is likely never going to be an issue for Rucio, but I still wanted to open an issue to discuss this.Additionally, when
assert
fails, it raisesAssertionError
. In the context of our usage ofassert
, I think we could raise more specific exceptions with clearer messages, which might also help from the point of view of debugging.To do
I would like us to decide on one of these options:
assert
is fine. In this case, we only need to set the linter to ignoreS101
(usage ofassert
) and no other changes will be needed.assert
with regular condition checking and custom exceptions. In this case, we'd need to make these changes.See also
Linter log
The text was updated successfully, but these errors were encountered: