Implement the pylint rule PLW1514 (unspecified-encoding)#7939
Merged
charliermarsh merged 3 commits intoastral-sh:mainfrom Oct 17, 2023
Merged
Implement the pylint rule PLW1514 (unspecified-encoding)#7939charliermarsh merged 3 commits intoastral-sh:mainfrom
charliermarsh merged 3 commits intoastral-sh:mainfrom
Conversation
Contributor
PR Check ResultsEcosystemℹ️ 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
|
| .is_none() | ||
| } | ||
| _ => false, | ||
| } |
Member
There was a problem hiding this comment.
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?
Member
There was a problem hiding this comment.
Ahh, I guess we can't include the pathlib cases since those are instance methods.
Contributor
Author
There was a problem hiding this comment.
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. =(
eb576c0 to
6c958f8
Compare
charliermarsh
approved these changes
Oct 17, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.