Skip to content

Commit 0d451ec

Browse files
committed
Pre-commit update
1 parent c241140 commit 0d451ec

File tree

6 files changed

+53
-99
lines changed

6 files changed

+53
-99
lines changed

.eslintrc.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
env:
2+
browser: true
3+
jquery: true
4+
es6: true
5+
parserOptions:
6+
ecmaVersion: 2018

.github/workflows/build.yml

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -29,79 +29,28 @@ jobs:
2929
name: dist
3030
path: dist
3131

32-
lint-black:
33-
name: 🧹 black
32+
pre-commit:
33+
name: 🧹 Pre-commit
3434
runs-on: ubuntu-latest
3535
steps:
36-
- uses: actions/checkout@v2
37-
- name: 🏗 Set up Python 3.7
38-
uses: actions/setup-python@v1
39-
with:
40-
python-version: 3.7
41-
- name: 🏗 Set up dev dependencies
42-
run: |
43-
pip install -e .[develop]
44-
- name: 🚀 Run black
45-
run: |
46-
pre-commit run --hook-stage manual black --all-files --show-diff-on-failure
47-
48-
lint-prettier:
49-
name: 🧹 prettier
50-
runs-on: ubuntu-latest
51-
steps:
52-
- uses: actions/checkout@v2
53-
- name: 🏗 Set up Python 3.7
54-
uses: actions/setup-python@v1
55-
with:
56-
python-version: 3.7
57-
- name: 🏗 Set up dev dependencies
58-
run: |
59-
pip install -e .[develop]
60-
- name: 🚀 Run prettier
61-
run: |
62-
pre-commit run --hook-stage manual prettier --all-files --show-diff-on-failure
63-
64-
lint-isort:
65-
name: 🧹 isort
66-
runs-on: ubuntu-latest
67-
steps:
68-
- uses: actions/checkout@v2
69-
- name: 🏗 Set up Python 3.7
70-
uses: actions/setup-python@v1
36+
- uses: actions/checkout@v3
37+
- name: 🏗 Set up Python 3.10
38+
uses: actions/setup-python@v4
7139
with:
72-
python-version: 3.7
73-
- name: 🏗 Set up dev dependencies
74-
run: |
75-
pip install -e .[develop]
76-
- name: 🚀 Run isort
77-
run: |
78-
pre-commit run --hook-stage manual isort --all-files --show-diff-on-failure
79-
80-
lint-flake8:
81-
name: 🧹 Flake8
82-
runs-on: ubuntu-latest
83-
steps:
84-
- uses: actions/checkout@v2
85-
- name: 🏗 Set up Python 3.7
86-
uses: actions/setup-python@v1
87-
with:
88-
python-version: 3.7
89-
- name: 🏗 Set up dev dependencies
40+
python-version: "3.10"
41+
- name: 🏗 Set up pre-commit
9042
run: |
91-
pip install -e .[develop]
92-
- name: 🚀 Run flake8
43+
pip install pre-commit
44+
- name: 🚀 Run pre-commit
9345
run: |
94-
pre-commit run --hook-stage manual flake8 --all-files
46+
pre-commit run --all-files --show-diff-on-failure
9547
9648
publish-on-testpypi:
9749
name: 📦 Publish on TestPyPI
9850
if: github.event_name == 'release'
9951
needs:
10052
- build
101-
- lint-black
102-
- lint-prettier
103-
- lint-isort
104-
- lint-flake8
53+
- pre-commit
10554
runs-on: ubuntu-latest
10655
steps:
10756
- name: ⬇ Download build result

.pre-commit-config.yaml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
exclude: ^(src/octoprint/vendor/|src/octoprint/static/js/lib|src/octoprint/static/vendor|tests/static/js/lib|tests/util/_files|docs/|scripts/|translations/|.*\.css|.*\.svg)
1+
exclude: ^(octoprint_file_check/translations|extras/|translations/|.*\.css|.*\.svg)
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v2.3.0
4+
rev: v4.4.0
55
hooks:
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
@@ -11,30 +11,39 @@ repos:
1111
- id: check-toml
1212
- id: check-merge-conflict
1313
- id: fix-encoding-pragma
14+
args: ["--remove"]
15+
- repo: https://github.com/asottile/pyupgrade
16+
rev: v3.3.1
17+
hooks:
18+
- id: pyupgrade
19+
args: ["--py37-plus"]
1420
- repo: https://github.com/OctoPrint/codemods
15-
rev: devel
21+
rev: "0.6.3"
1622
hooks:
17-
- id: codemod_dict_to_literal
18-
stages: ["manual"]
19-
- id: codemod_set_to_literal
20-
stages: ["manual"]
2123
- id: codemod_not_in
22-
stages: ["manual"]
2324
- repo: https://github.com/pre-commit/mirrors-isort
24-
rev: v5.5.4
25+
rev: v5.10.1
2526
hooks:
2627
- id: isort
2728
- repo: https://github.com/psf/black
28-
rev: 22.3.0
29+
rev: 23.1.0
2930
hooks:
3031
- id: black
31-
- repo: https://gitlab.com/pycqa/flake8
32-
rev: 3.8.1
32+
- repo: https://github.com/pycqa/flake8
33+
rev: 6.0.0
3334
hooks:
3435
- id: flake8
3536
additional_dependencies:
3637
- flake8-bugbear
3738
- repo: https://github.com/pre-commit/mirrors-prettier
38-
rev: v2.1.2
39+
rev: v3.0.0-alpha.4
3940
hooks:
4041
- id: prettier
42+
- repo: https://github.com/pre-commit/mirrors-eslint
43+
rev: v8.33.0
44+
hooks:
45+
- id: eslint
46+
additional_dependencies:
47+
48+
49+
files: \.js$

octoprint_file_check/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import, division, print_function, unicode_literals
3-
41
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
52
__copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License"
63

7-
import io
84
import re
95

106
# noinspection PyCompatibility
@@ -111,7 +107,7 @@ def _search_through_file(self, path, term, incl_comments=False):
111107
return False
112108

113109
def _search_through_file_python(self, path, term, compiled, incl_comments=False):
114-
with io.open(path, mode="r", encoding="utf8", errors="replace") as f:
110+
with open(path, encoding="utf8", errors="replace") as f:
115111
for line in f:
116112
if term in line and (incl_comments or compiled.match(line)):
117113
return True

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ universal = 1
66

77
[flake8]
88
max-line-length = 90
9-
extend-ignore = E203, E231, E265, E266, E402, E501, E731
9+
extend-ignore = E203, E231, E265, E266, E402, E501, E731, B950, W503, W504, W605
1010
select = B,C,E,F,W,T4,B9
1111

1212
[isort]

setup.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
########################################################################################################################
42
### Do not forget to adjust the following variables to your own plugin.
53

@@ -463,9 +461,7 @@ def run(self):
463461
shutil.rmtree(target_path)
464462

465463
print(
466-
"Copying translations for locale {locale} from {source_path} to {target_path}...".format(
467-
**locals()
468-
)
464+
f"Copying translations for locale {locale} from {source_path} to {target_path}..."
469465
)
470466
shutil.copytree(source_path, target_path)
471467

@@ -533,7 +529,7 @@ def run(self):
533529
date=now.strftime("%Y%m%d%H%M%S"),
534530
),
535531
)
536-
print("Packing translation to {zip_path}".format(**locals()))
532+
print(f"Packing translation to {zip_path}")
537533

538534
def add_recursively(zip, path, prefix):
539535
if not os.path.isdir(path):
@@ -545,12 +541,12 @@ def add_recursively(zip, path, prefix):
545541
if os.path.isdir(entry_path):
546542
add_recursively(zip, entry_path, new_prefix)
547543
elif os.path.isfile(entry_path):
548-
print("Adding {entry_path} as {new_prefix}".format(**locals()))
544+
print(f"Adding {entry_path} as {new_prefix}")
549545
zip.write(entry_path, new_prefix)
550546

551-
meta_str = "last_update: {date}\n".format(date=now.isoformat())
547+
meta_str = f"last_update: {now.isoformat()}\n"
552548
if self.author:
553-
meta_str += "author: {author}\n".format(author=self.author)
549+
meta_str += f"author: {self.author}\n"
554550

555551
zip_locale_root = self.__class__.pack_path_prefix + locale
556552

@@ -559,7 +555,7 @@ def add_recursively(zip, path, prefix):
559555
with zipfile.ZipFile(zip_path, "w") as zip:
560556
add_recursively(zip, locale_dir, zip_locale_root)
561557

562-
print("Adding meta.yaml as {zip_locale_root}/meta.yaml".format(**locals()))
558+
print(f"Adding meta.yaml as {zip_locale_root}/meta.yaml")
563559
zip.writestr(zip_locale_root + "/meta.yaml", meta_str)
564560

565561

@@ -630,7 +626,7 @@ def create_plugin_setup_parameters(
630626
import pkg_resources
631627

632628
if package is None:
633-
package = "octoprint_{identifier}".format(**locals())
629+
package = f"octoprint_{identifier}"
634630

635631
if additional_data is None:
636632
additional_data = list()
@@ -686,8 +682,8 @@ def create_plugin_setup_parameters(
686682
pot_file=pot_file,
687683
output_dir=translation_dir,
688684
bundled_dir=bundled_dir,
689-
pack_name_prefix="{name}-i18n-".format(**locals()),
690-
pack_path_prefix="_plugins/{identifier}/".format(**locals()),
685+
pack_name_prefix=f"{name}-i18n-",
686+
pack_path_prefix=f"_plugins/{identifier}/",
691687
)
692688
)
693689

@@ -697,13 +693,13 @@ def create_plugin_setup_parameters(
697693
[package]
698694
+ list(
699695
filter(
700-
lambda x: x.startswith("{package}.".format(package=package)),
696+
lambda x: x.startswith(f"{package}."),
701697
find_packages(where=source_folder, exclude=ignored_packages),
702698
)
703699
)
704700
+ additional_packages
705701
)
706-
print("Found packages: {packages!r}".format(**locals()))
702+
print(f"Found packages: {packages!r}")
707703

708704
return dict(
709705
name=name,
@@ -733,9 +729,7 @@ def create_plugin_setup_parameters(
733729
dependency_links=dependency_links,
734730
# Hook the plugin into the "octoprint.plugin" entry point, mapping the plugin_identifier to the plugin_package.
735731
# That way OctoPrint will be able to find the plugin and load it.
736-
entry_points={
737-
"octoprint.plugin": ["{identifier} = {package}".format(**locals())]
738-
},
732+
entry_points={"octoprint.plugin": [f"{identifier} = {package}"]},
739733
)
740734

741735

0 commit comments

Comments
 (0)