Skip to content

Commit

Permalink
fix: Correct flake8 config
Browse files Browse the repository at this point in the history
- Add exclude pattern for flake8 when running with pre-commit as it does
  not fully honor the exclude paths.
- Cleanup exclude paths for flake8 in tox.ini
- Re-enable line length check and correct three affected files
  • Loading branch information
arsenetar committed Jan 10, 2023
1 parent 2dd2a80 commit 6db2fa2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
exclude: ^(.tox|env|build|dist|help|qt/dg_rc.py|pkg).*
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.3.0
hooks:
Expand Down
9 changes: 6 additions & 3 deletions core/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ class FilesDB:
schema_version = 1
schema_version_description = "Changed from md5 to xxhash if available."

create_table_query = "CREATE TABLE IF NOT EXISTS files (path TEXT PRIMARY KEY, size INTEGER, mtime_ns INTEGER, entry_dt DATETIME, digest BLOB, digest_partial BLOB, digest_samples BLOB)"
create_table_query = """CREATE TABLE IF NOT EXISTS files (path TEXT PRIMARY KEY, size INTEGER, mtime_ns INTEGER,
entry_dt DATETIME, digest BLOB, digest_partial BLOB, digest_samples BLOB)"""
drop_table_query = "DROP TABLE IF EXISTS files;"
select_query = "SELECT {key} FROM files WHERE path=:path AND size=:size and mtime_ns=:mtime_ns"
select_query_ignore_mtime = "SELECT {key} FROM files WHERE path=:path AND size=:size"
insert_query = """
INSERT INTO files (path, size, mtime_ns, entry_dt, {key}) VALUES (:path, :size, :mtime_ns, datetime('now'), :value)
INSERT INTO files (path, size, mtime_ns, entry_dt, {key})
VALUES (:path, :size, :mtime_ns, datetime('now'), :value)
ON CONFLICT(path) DO UPDATE SET size=:size, mtime_ns=:mtime_ns, entry_dt=datetime('now'), {key}=:value;
"""

Expand Down Expand Up @@ -153,7 +155,8 @@ def get(self, path: Path, key: str) -> Union[bytes, None]:
self.cur.execute(self.select_query_ignore_mtime.format(key=key), {"path": str(path), "size": size})
else:
self.cur.execute(
self.select_query.format(key=key), {"path": str(path), "size": size, "mtime_ns": mtime_ns}
self.select_query.format(key=key),
{"path": str(path), "size": size, "mtime_ns": mtime_ns},
)
result = self.cur.fetchone()

Expand Down
4 changes: 2 additions & 2 deletions qt/exclude_list_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def display_help_message(self):
in the Directories tab if their name happens to match one of the selected regular expressions.<br>\
For each file collected, two tests are performed to determine whether or not to completely ignore it:<br>\
<li>1. Regular expressions with no path separator in them will be compared to the file name only.</li>
<li>2. Regular expressions with at least one path separator in them will be compared to the full path to the file.</li><br>
Example: if you want to filter out .PNG files from the "My Pictures" directory only:<br>\
<li>2. Regular expressions with at least one path separator in them will be compared to the full path to the file.</li>\
<br>Example: if you want to filter out .PNG files from the "My Pictures" directory only:<br>\
<code>.*My\\sPictures\\\\.*\\.png</code><br><br>\
You can test the regular expression with the "test string" button after pasting a fake path in the test field:<br>\
<code>C:\\\\User\\My Pictures\\test.png</code><br><br>
Expand Down
6 changes: 4 additions & 2 deletions qt/preferences_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def _setupDisplayPage(self):
)
self.use_native_dialogs.setToolTip(
tr(
"For actions such as file/folder selection use the OS native dialogs.\nSome native dialogs have limited functionality."
"For actions such as file/folder selection use the OS native dialogs.\n\
Some native dialogs have limited functionality."
)
)
layout.addWidget(self.use_native_dialogs)
Expand Down Expand Up @@ -217,7 +218,8 @@ def _setupDisplayPage(self):
def _setup_advanced_page(self):
tab_label = QLabel(
tr(
"These options are for advanced users or for very specific situations, most users should not have to modify these."
"These options are for advanced users or for very specific situations, \
most users should not have to modify these."
),
wordWrap=True,
)
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ deps =
-r{toxinidir}/requirements-extra.txt

[flake8]
exclude = .tox,env,build,cocoalib,cocoa,help,./qt/dg_rc.py,cocoa/run_template.py,./pkg
exclude = .tox,env*,build,help,qt/dg_rc.py,pkg
max-line-length = 120
select = C,E,F,W,B,B950
extend-ignore = E203, E501, W503
extend-ignore = E203,W503

0 comments on commit 6db2fa2

Please sign in to comment.