From ec13884eeb118f579351dc70a456aabb15917310 Mon Sep 17 00:00:00 2001 From: buhtz Date: Thu, 16 Nov 2023 09:22:48 +0100 Subject: [PATCH] build: Codespell setup & PyLint W1401 Add codespell config. Activate PyLint warning W1401 (anomalous-backslash-in-string). --- .codespellrc | 29 +++++++++ CHANGES | 14 +++-- FAQ.md | 4 +- README.md | 2 +- common/config.py | 2 +- common/create-manpage-backintime-config.py | 2 +- common/doc-dev/BiT_release_process.md | 73 +++++++++++----------- common/doc-dev/conf.py | 6 +- common/encfstools.py | 3 +- common/pluginmanager.py | 4 +- common/plugins/usercallbackplugin.py | 2 +- common/test/generic.py | 2 +- common/test/test_backintime.py | 2 +- common/test/test_lint.py | 4 +- common/tools.py | 4 +- qt/test/test_lint.py | 4 +- update_language_files.py | 2 +- 17 files changed, 93 insertions(+), 66 deletions(-) create mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 000000000..b7e0492a4 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,29 @@ +[codespell] +# Folders and files to skip +skip = .codespellrc,*.po,Makefile,*.desktop,.git,__pycache__,*.pyc,languages.py +# Print N lines of surrounding context +context = 1 +# Check hidden files also (empty means True) +check-hidden= +# Print number of errors as last line on stderr (empty means True) +count= + +# Dictionaries to use (default: "clear,rare"). Current: all. +builtin = clear,rare,informal,usage,code,names,en-GB_to_en-US + +# Allowed (ignored) words +ignore-words-list=master,whitelist,manuel,dum +# Allowed (ignored) words in URLs and URIs +uri-ignore-words-list=mitre + +# Good to know about allowed/ignored words: +# Codespell acts a bit unusual when it comes to case-sensitivity. +# By default the word "Manuel" is an error and codespell recommends to +# modify it into "Manual". Tu allow this German name "Manuel" we have to +# add "manual" (lower case!) to the "ignore-words-list". The upper-case +# version do not work. +# See: https://github.com/codespell-project/codespell/issues/3210 + +# Simulate "# noqa" and ignore all lines with "# codespell-ignore" at the end. +# Credits: https://github.com/codespell-project/codespell/issues/1212#issuecomment-1721152455 +ignore-regex=.*# codespell-ignore$ diff --git a/CHANGES b/CHANGES index 4401d82b4..ac8ef7f6f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,12 +1,14 @@ Back In Time Version 1.4.2-dev (development of upcoming release) -* Fix bug: RTE: module 'qttools' has no attribute 'initate_translator' with encFS when prompting the user for a password (#1553) +* Fix bug: RTE: module 'qttools' has no attribute 'initate_translator' with encFS when prompting the user for a password (#1553). * Build: Use PyLint in unit testing to catch E1101 (no-member) errors. +* Build: Activate PyLint warning W1401 (anomalous-backslash-in-string). +* Build: Add codespell config. * Translation: Minor modifications in source strings and updating language files. Version 1.4.1 (2023-10-01) -* Dependency: Add "qt translations" to GUI runtime dependencies (#1538) +* Dependency: Add "qt translations" to GUI runtime dependencies (#1538). * Build: Unit tests do generically ignore all instead of well-known warnings now (#1539). * Build: Warnings about missing Qt translation now are ignored while testing (#1537). * Fix bug: GUI didn't start when "show hidden files" button was on (#1535). @@ -113,7 +115,7 @@ Version 1.2.0 (2019-04-27) * Fix bug: 23:00 is missing in the list of every day hours (https://github.com/bit-team/backintime/issues/736) * Fix bug: ssh-agent output changed (https://github.com/bit-team/backintime/issues/840) * remove unused and undocumented userscript plugin -* Fix bug: exception on making backintime folder world writeable (https://github.com/bit-team/backintime/issues/812) +* Fix bug: exception on making backintime folder world writable (https://github.com/bit-team/backintime/issues/812) * Fix bug: stat free space for snapshot folder instead of backintime folder (https://github.com/bit-team/backintime/issues/733) * add contextmenu for logview dialog which can copy, exclude and decode lines * move progressbar under statusbar @@ -250,7 +252,7 @@ Version 1.1.10 (2016-01-09) * Fix bug: FileNotFoundError while starting pw-cache from source * continue an unfinished new_snapshot if possible (https://github.com/bit-team/backintime/issues/400) * Fix bug: suppress warning about failed inhibit suspend if run as root (https://github.com/bit-team/backintime/issues/500) -* Fix bug: UI blocked/greyed out while removing snapshot (https://github.com/bit-team/backintime/issues/487) +* Fix bug: UI blocked/grayed out while removing snapshot (https://github.com/bit-team/backintime/issues/487) * Fix bug: pw-cache failed on leftover PID file, using ApplicationInstance now (https://github.com/bit-team/backintime/issues/468) * Fix bug: failed to parse some arguments (https://github.com/bit-team/backintime/issues/492) * Fix bug: failed to start GUI if launched from systray icon @@ -268,7 +270,7 @@ Version 1.1.8 (2015-09-28) * show current app name and profile ID in syslog (https://launchpad.net/bugs/906213) * Fix bug: BiT freeze when activate 'Decode path' in 'Snapshot Log View' * Show 'Profiles' dropdown only in 'Last Log Viewer', add 'Snapshots' dropdown in 'Snapshot Log Viewer' (https://launchpad.net/bugs/1478219) -* Fix bug: empty grey window appears when starting the gui as root (https://launchpad.net/bugs/1493020) +* Fix bug: empty gray window appears when starting the gui as root (https://launchpad.net/bugs/1493020) * do not restore permission if they are identical with current permissions * Fix bug: gnu_find_suffix_support doesn't set back to True (https://launchpad.net/bugs/1487781) * security issue: do not run user-callback in a shell @@ -335,7 +337,7 @@ Version 1.1.4 (2015-03-22) * Fix bug: OSError in free_space; add alternate method to get free space * add bash-completion * Fix bug: ugly theme while running as root on Gnome based DEs (https://launchpad.net/bugs/1418447) -* Fix bug: filename with broken charset throwed UnicodeError exception (https://launchpad.net/bugs/1419694) +* Fix bug: UnicodeError thrown if filename has broken charset (https://launchpad.net/bugs/1419694) * use 'crontab' instead of 'crontab -' to read from stdin (https://launchpad.net/bugs/1419466) Version 1.1.2 (2015-02-04) diff --git a/FAQ.md b/FAQ.md index 0b53a7016..1b2b956df 100644 --- a/FAQ.md +++ b/FAQ.md @@ -657,7 +657,7 @@ permissions were set to `-rw-r--r--`. In 1.2.0 rsync is executed with `--perms` option which tells rsync to preserve the source file permission. That's why so many files seem to be changed. -If you don't like the new behaviour, you can use "Expert Options" +If you don't like the new behavior, you can use "Expert Options" -> "Paste additional options to rsync" to add the value `--no-perms --no-group --no-owner` in that field. @@ -914,7 +914,7 @@ For detailed setup instructions see the [how to setup openssh for unit tests](co The goal is to log into the SSH server on your local computer via `ssh localhost` without using a password: -- Generate an RSA keypair executing `ssh-keygen`. Use the default file name +- Generate an RSA key pair executing `ssh-keygen`. Use the default file name and don't use a passphrase for the key. - Populate the public key to the server executing `ssh-copy-id`. - Make the `ssh` instance run. diff --git a/README.md b/README.md index 0e66ba066..30605b348 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You only need to specify 3 things: A small team (Christian Buhtz, Michael Büker and Jürgen Altfeld) has started in summer 2022 to get things moving again after the development of this project has been dormant for a while. -We do the development in our spare time and have to prioritise so +We do the development in our spare time and have to prioritize so stick with us, we all ♥️ _Back In Time_. 😁 We are currently focusing on fixing diff --git a/common/config.py b/common/config.py index b97e57b02..acb73e3ff 100644 --- a/common/config.py +++ b/common/config.py @@ -1609,7 +1609,7 @@ def removeOldCrontab(self, crontab): if not self.SYSTEM_ENTRY_MESSAGE in crontab: #Then the system entry message has not yet been used in this crontab #therefore we assume all entries are system entries and clear them all. - #This is the old behaviour + #This is the old behavior logger.debug("Clearing all Back In Time entries", self) return [x for x in crontab if not 'backintime' in x] else: diff --git a/common/create-manpage-backintime-config.py b/common/create-manpage-backintime-config.py index 130853b60..cb93eb79a 100644 --- a/common/create-manpage-backintime-config.py +++ b/common/create-manpage-backintime-config.py @@ -23,7 +23,7 @@ other information. The founder of that script @Germar gave a detailed description about that script in #1354. -The script reads every line and tries to analyse it: +The script reads every line and tries to analyze it: - It searches for `DEFAULT` and puts those into a `dict` for later replacing the variable with the value. - If that didn't match it will look for lines starting with `#?` which is diff --git a/common/doc-dev/BiT_release_process.md b/common/doc-dev/BiT_release_process.md index c62b070d2..d7f266628 100644 --- a/common/doc-dev/BiT_release_process.md +++ b/common/doc-dev/BiT_release_process.md @@ -13,34 +13,34 @@ using a "feature" branch and sending a pull request asking for a review. ## Preconditions for a new release -- Developers agreed on the new version number -- Most-recent translations were merged into `dev` branch -- `dev` version was tested (CLI in `common` and GUI in `qt`) and testers/developers agreed on "readiness to be released" -- Full CI build pipeline matrix was activated, see: - https://github.com/bit-team/backintime/pull/1529 +- Developers agreed on the new version number. +- Most-recent translations were merged into `dev` branch. See the [localization docu](2_localization.md). +- Full CI build pipeline matrix is activate (see [#1529](https://github.com/bit-team/backintime/issues/1529)). +- `dev` version was tested (CLI in `common` and GUI in `qt`) and testers/developers agreed on "readiness to be released". ## TLDR ;-) -- Create a new branch in your clone for the new release candidate -- Update `VERSION` file -- Update `CHANGES` file -- Execute the script `./updateversion.sh` +- Create a new branch in your clone for the new release candidate. +- Update `VERSION` file. +- Update `CHANGES` file. +- Execute the script `./updateversion.sh` to update the version numbers (based on `VERSION` file) in several files. - Update the "as at" date in the man page files `backintime.1` and `backintime-askpass.1`. - Autogenerate and update the man page file `backintime-config.1` by executing the script `common/create-manapge-backintime-config.py`. -- Update `README.md` file -- Commit -- Open a new pull request (PR) +- Update `README.md` file. +- Run `codespell` to check for common spelling errors. +- Commit the changes. +- Open a new pull request (PR) for review by other developers. When the PR is merged: -- Create a new tar archive (eg. `backintime-1.4.0.tar.gz`) with `./make-tarball.sh` -- Create a new release in Github (attaching above tar archive) -- Update `VERSION` and `CHANGES` for the `dev` branch +- Create a new tar archive (eg. `backintime-1.4.0.tar.gz`) with `./make-tarball.sh`. +- Create a new release in Github (attaching above tar archive). +- Update `VERSION` and `CHANGES` for the `dev` branch. ## Step by step -- Announce code freeze on `dev` branch to all active developers via email +- Announce code freeze on `dev` branch to all active developers via email. - Check that Travis CI did successfully build the latest `dev` branch commit: @@ -80,7 +80,7 @@ When the PR is merged: ``` - Use a linter like [`pylint`](https://pypi.org/project/pylint/) to identify code errors that are not obvious but - may be found only (too late) at run-time, eg. object name typos (see eg. #1553). + may be found only (too late) at run-time, eg. object name typos (see e.g. [#1553](https://github.com/bit-team/backintime/issues/1553)). - Update the `CHANGES` text file in the project's root folder: @@ -106,7 +106,7 @@ When the PR is merged: - Execute the script `./updateversion.sh` in the project's root folder to automatically update the version number in multiple files using the version number from the `VERSION` file - (so you do not forget to update one file ;-) + (so you do not forget to update one file ;-). - BiT CLI config in `common/config.py` - Sphinx config in `common/doc-dev/conf.py` @@ -114,7 +114,7 @@ When the PR is merged: - changelog to build a debian package in `debian/changelog` (this will be deprecated once we give up or separate the packaging for distros) -- Check that the version numbers have been update by opening some of the above files +- Check that the version numbers have been update by opening some of the above files. - Update the "as at" date in the man page files (in `common/man/C/backintime*.1` and `qt/man/C/backintime*.1`) manually by changing the month and year in the first line that looks like this: @@ -159,19 +159,21 @@ When the PR is merged: make ``` -- Do a manual smoke and UAT ("user acceptance test") of the GUI +- Execute [`codespell`](https://pypi.org/project/codespell) in the repositories root folder to check for common spelling errors. + +- Do a manual smoke and UAT ("user acceptance test") of the GUI. - If you find bugs: - - Open an issue - - Decide if you want to fix this in the release candidate - - If you fix it in the release candidate: Update the CHANGES file (add the issue number + description) + - Open an issue. + - Decide if you want to fix this in the release candidate. + - If you fix it in the release candidate: Update the CHANGES file (add the issue number + description). - If you don't fix it (eg. too risky) and it is a HIGH bug: - Add the bug to the [Known Problems and Workarounds](https://github.com/bit-team/backintime#known-problems-and-workarounds) section of `README.md` (of the release candidate branch) and describe - a workaround (if any) + a workaround (if any). -- Commit and push, if no "show-stopping" bug exists +- Commit and push, if no "show-stopping" bug exists. Note: To push your release candidate branch into a new remote branch use: ``` @@ -180,21 +182,21 @@ When the PR is merged: - Open a new pull request for your pushed release candidate branch: - - Add all developers as reviewers + - Add all developers as reviewers. - Mention bugs (and status) discovered during preparation of the release candidate - in the description + in the description. -- Fix review findings and push the changes again to update the pull request +- Fix review findings and push the changes again to update the pull request. -- Finally check the Travis CI status of the pull request (everything must be green) +- Finally check the Travis CI status of the pull request (everything must be green). - Once all the PR reviewer approved the PR do a squash-merge (= all changes are "squashed" into one commit) into the `dev` branch using a commit message like - `Release candidate for v1.4.1 (Oct. 1, 2023) ` + `Release candidate for v1.4.1 (Oct. 1, 2023)` - Wait for the final Travis CI build on the `dev` branch and check - if everything is OK to proceed with the release + if everything is OK to proceed with the release. - Create the tarball archive files to be attached as "binaries" to the release: - Update the `dev` branch @@ -280,12 +282,7 @@ When the PR is merged: ### "Read the docs" code documentation -The "Read the docs" site is automatically updated with every commit on the `dev` branch: - -https://github.com/bit-team/backintime/pull/1533#issuecomment-1720897669 - -https://readthedocs.org/projects/backintime-dev/ - +The "Read the docs" site is automatically updated with every commit on the `dev` branch. See [Issue #1533](https://github.com/bit-team/backintime/pull/1533#issuecomment-1720897669) and the [_backintime-dev_ project](https://readthedocs.org/projects/backintime-dev) at Read the docs. ### Building `deb` package files @@ -294,3 +291,5 @@ We do no longer maintain and publish `deb` package files. To build your own `deb` file see: https://github.com/bit-team/backintime/blob/dev/CONTRIBUTING.md#build-own-deb-file + +November 2023 \ No newline at end of file diff --git a/common/doc-dev/conf.py b/common/doc-dev/conf.py index 16ff83ca8..cc030ae1d 100644 --- a/common/doc-dev/conf.py +++ b/common/doc-dev/conf.py @@ -60,11 +60,7 @@ copyright = '2016, Germar Reitze' author = 'Germar Reitze' -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. +# Don't edit this variable. It is updated automatically by "updateversion.sh". version = '1.4.2-dev' # The full version, including alpha/beta/rc tags. release = version # '1.3.3-dev' diff --git a/common/encfstools.py b/common/encfstools.py index f375df5b9..e989d775f 100644 --- a/common/encfstools.py +++ b/common/encfstools.py @@ -519,7 +519,8 @@ def __init__(self, cfg, string = True): #precompile some regular expressions host, port, user, path, cipher = cfg.sshHostUserPortPathCipher() #replace: --exclude"" or --include"" - self.re_include_exclude = re.compile(r'(--(?:ex|in)clude=")(.*?)(")') + self.re_include_exclude = re.compile( + r'(--(?:ex|in)clude=")(.*?)(")') # codespell-ignore #replace: 'USER@HOST:"PATH"' self.re_remote_path = re.compile(r'(\'%s@%s:"%s)(.*?)("\')' %(user, host, path)) diff --git a/common/pluginmanager.py b/common/pluginmanager.py index 537650185..48731ba4a 100644 --- a/common/pluginmanager.py +++ b/common/pluginmanager.py @@ -29,11 +29,11 @@ from exceptions import StopException class Plugin: - """ Interface methods to customize behaviour for different backup steps + """ Interface methods to customize behavior for different backup steps Back In Time allows to inform plugins (implemented in Python files) about different steps ("events") in the backup process. - Plugins may implement special behaviour to predefined + Plugins may implement special behavior to predefined "events" that are declared in this interface class as methods. diff --git a/common/plugins/usercallbackplugin.py b/common/plugins/usercallbackplugin.py index 0469b63f5..6f8a4699c 100644 --- a/common/plugins/usercallbackplugin.py +++ b/common/plugins/usercallbackplugin.py @@ -27,7 +27,7 @@ class UserCallbackPlugin(pluginmanager.Plugin): - """ Executes a script file at different backup steps to customize behaviour + """ Executes a script file at different backup steps to customize behavior Back In Time allows to inform plugins (implemented in Python files) about different steps ("events") in the backup process diff --git a/common/test/generic.py b/common/test/generic.py index e4136818a..682d11a33 100644 --- a/common/test/generic.py +++ b/common/test/generic.py @@ -43,7 +43,7 @@ tools.registerBackintimePath('qt', 'plugins') TMP_FLOCK = NamedTemporaryFile(prefix='backintime', suffix='.flock') -# A simple (local) RSA keypair via "ssh-keygen" and activate it +# A simple (local) RSA key pair via "ssh-keygen" and activate it # via "ssh-copy-id localhost". PRIV_KEY_FILE = pathlib.Path.home() / '.ssh' / 'id_rsa' PUBLIC_KEY_FILE = PRIV_KEY_FILE.with_suffix('.pub') diff --git a/common/test/test_backintime.py b/common/test/test_backintime.py index 903701c4b..706a0d160 100644 --- a/common/test/test_backintime.py +++ b/common/test/test_backintime.py @@ -48,7 +48,7 @@ def test_local_snapshot_is_successful(self): Development notes (by Buhtz): Multiple tests do compare return codes and output on stdout. The intention might be an integration tests. But the asserts not qualified - to answer the important questions and observe the intended behaviour. + to answer the important questions and observe the intended behavior. Heavy refactoring is needed. But because of the "level" of that tests it won't happen in the near future. """ diff --git a/common/test/test_lint.py b/common/test/test_lint.py index a3d02c2a3..149d9c870 100644 --- a/common/test/test_lint.py +++ b/common/test/test_lint.py @@ -54,10 +54,10 @@ def test_with_pylint(self): '--disable=all' ] - # Explicite activate checks + # Explicit activate checks err_codes = [ 'E1101', # no-member - # 'W0613', # unused-argument + 'W1401', # anomalous-backslash-in-string (invalid escape sequence) ] cmd.append('--enable=' + ','.join(err_codes)) diff --git a/common/tools.py b/common/tools.py index 84a35659b..95eb848f1 100644 --- a/common/tools.py +++ b/common/tools.py @@ -217,7 +217,7 @@ def get_available_language_codes(): def get_language_names(language_code): - """Return a list with language names in three different flavours. + """Return a list with language names in three different flavors. Language codes from `get_available_language_codes()` are combined with `languages.language_names` to prepare the list. @@ -264,7 +264,7 @@ def get_language_names(language_code): def get_native_language_and_completeness(language_code): - """Return the language name in its native flavour and the completeness of + """Return the language name in its native flavor and the completeness of its translation in percent. Args: diff --git a/qt/test/test_lint.py b/qt/test/test_lint.py index b8d917684..8ebd1e3bf 100644 --- a/qt/test/test_lint.py +++ b/qt/test/test_lint.py @@ -53,10 +53,10 @@ def test_with_pylint(self): '--disable=all' ] - # Explicite activate checks + # Explicit activate checks err_codes = [ 'E1101', # no-member - # 'W0613', # unused-argument + 'W1401', # anomalous-backslash-in-string (invalid escape sequence) ] cmd.append('--enable=' + ','.join(err_codes)) diff --git a/update_language_files.py b/update_language_files.py index 38d9f6057..52a732acf 100755 --- a/update_language_files.py +++ b/update_language_files.py @@ -241,7 +241,7 @@ def create_languages_file(): def create_language_names_dict(language_codes: list) -> dict: - """Create dict of language names in different flavours. + """Create dict of language names in different flavors. The dict is used in the LanguageDialog to display the name of each language in the UI's current language and the language's own native representation.