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

Implement the pylint rule PLW1514 (unspecified-encoding) #7939

Merged
merged 3 commits into from
Oct 17, 2023

Conversation

shager
Copy link
Contributor

@shager shager commented Oct 13, 2023

Summary

Implemented the pylint rule W1514 ( unspecified-encoding).
See also: https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/unspecified-encoding.html

Test Plan

Tested it with the submitted test case.
Additionally, we tested the new ruff rule (PLW1514) on our proprietary Python code base.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 13, 2023

PR Check Results

Ecosystem

ℹ️ ecosystem check detected changes. (+60, -0, 0 error(s))

rotki (+60, -0)

+ package.py:477:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ package.py:484:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ package.py:512:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ packaging/docker/entrypoint.py:60:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/chain/ethereum/airdrops.py:301:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/chain/ethereum/airdrops.py:309:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/chain/ethereum/airdrops.py:331:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/chain/ethereum/airdrops.py:334:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/chain/ethereum/modules/dxdaomesa/decoder.py:45:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/db/dbhandler.py:276:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/externalapis/cryptocompare.py:830:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/externalapis/cryptocompare.py:848:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/assets_management.py:36:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v2_v3.py:546:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v3_v4.py:137:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v3_v4.py:153:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v3_v4.py:155:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v3_v4.py:307:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v3_v4.py:320:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/globaldb/upgrades/v4_v5.py:40:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_evm_transactions.py:111:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_history.py:408:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:205:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:212:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:221:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:228:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:237:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:244:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:253:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:261:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:271:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:278:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:328:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:353:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:377:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:396:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:572:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/api/test_snapshots.py:572:79: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/conftest.py:141:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/exchanges/test_kraken.py:207:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/external_apis/test_coingecko.py:93:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/external_apis/test_coingecko.py:96:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/unit/globaldb/test_upgrades.py:356:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/unit/globaldb/test_upgrades.py:51:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/unit/test_cost_basis.py:968:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/unit/test_eth2.py:159:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/accounting.py:270:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/accounting.py:294:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/history.py:1204:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/kraken.py:499:14: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/mock.py:245:22: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/mock.py:282:18: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/tests/utils/mock.py:294:22: PLW1514 `open` in text mode without explicit `encoding` argument
+ rotkehlchen/utils/snapshots.py:120:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ tools/profiling/graph.py:297:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ tools/profiling/graph.py:306:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ tools/scripts/generate_changelog.py:24:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ tools/scripts/generate_minimized_db_schema.py:61:6: PLW1514 `open` in text mode without explicit `encoding` argument
+ tools/scripts/pylint_useless_suppression.py:60:10: PLW1514 `open` in text mode without explicit `encoding` argument
+ tools/scripts/pylint_useless_suppression.py:72:10: PLW1514 `open` in text mode without explicit `encoding` argument

Rules changed: 1
Rule Changes Additions Removals
PLW1514 60 60 0

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Oct 13, 2023
@charliermarsh charliermarsh self-requested a review October 17, 2023 02:09
.is_none()
}
_ => false,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation overall looks really nice, but where this list come from? E.g., it looks like Pylint flags some of the pathlib methods -- should we flag those here too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I guess we can't include the pathlib cases since those are instance methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, we tried pathlib as well but it didn't work.
We also tried to detect something like this:

foo = open
foo("test.txt")

But we didn't manage to get this one right, so we omitted it. =(

@charliermarsh charliermarsh enabled auto-merge (squash) October 17, 2023 03:40
@charliermarsh charliermarsh merged commit 73049df into astral-sh:main Oct 17, 2023
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants