Skip to content

Commit 2c1caa2

Browse files
Switch to Ruff tools, update pre-commit (#558)
* Switch to Ruff tools, update pre-commit * Update .pre-commit-config.yaml --------- Co-authored-by: Marcelo Duarte Trevisani <marcelotrevisani@users.noreply.github.com>
1 parent 9d5d5e2 commit 2c1caa2

File tree

16 files changed

+118
-151
lines changed

16 files changed

+118
-151
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.isort.cfg

Lines changed: 0 additions & 7 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
11
exclude: docs
22
repos:
3-
- repo: https://github.com/psf/black
4-
rev: 24.8.0
5-
hooks:
6-
- id: black
7-
args: [--safe, --quiet]
8-
- repo: https://github.com/asottile/blacken-docs
3+
- repo: https://github.com/adamchainz/blacken-docs
94
rev: 1.18.0
105
hooks:
116
- id: blacken-docs
12-
additional_dependencies: [black==22.6.0]
7+
additional_dependencies: [black==22.12.0]
138
- repo: https://github.com/pre-commit/pre-commit-hooks
149
rev: v4.6.0
1510
hooks:
1611
- id: trailing-whitespace
1712
- id: end-of-file-fixer
18-
- id: fix-encoding-pragma
19-
args: [--remove]
2013
- id: check-yaml
2114
exclude: tests
2215
- id: sort-simple-yaml
23-
files: grayskull/pypi/config.yaml
16+
files: config.yaml
2417
- id: check-toml
2518
- id: check-json
2619
- id: check-merge-conflict
2720
- id: pretty-format-json
2821
args: [--autofix]
2922
- id: debug-statements
3023
language_version: python3
31-
- repo: https://github.com/PyCQA/isort
32-
rev: 5.13.2
33-
hooks:
34-
- id: isort
35-
exclude: tests/data
36-
- repo: https://github.com/PyCQA/flake8
37-
rev: 7.1.1
24+
- repo: https://github.com/astral-sh/ruff-pre-commit
25+
rev: v0.6.4
3826
hooks:
39-
- id: flake8
40-
exclude: tests/data
41-
language_version: python3
27+
# Run the linter
28+
- id: ruff
29+
args: [ --fix, --exit-non-zero-on-fix ]
30+
# Run the formatter
31+
- id: ruff-format

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ exclude .github
77
exclude azure-pipelines.yml
88
exclude .gitignore
99
exclude .pre-commit-config.yaml
10-
exclude .flake8
1110
exclude .coveragerc
12-
exclude .isort.cfg
1311
prune tests/
1412
recursive-exclude * __pycache__
1513
recursive-exclude * *.py[co]

grayskull/base/track_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def solve_pkg_name(pkg: str, config_file: Union[Path, str]) -> str:
5353
@lru_cache(maxsize=5)
5454
def _get_track_info_from_file(config_file: Union[Path, str]) -> Dict:
5555
yaml = YAML()
56-
with open(config_file, "r", encoding="utf_8") as yaml_file:
56+
with open(config_file, encoding="utf_8") as yaml_file:
5757
return yaml.load(yaml_file)
5858

5959

grayskull/cli/stdout.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ def print_req(list_pkg):
112112
f"\n{Fore.RED}RED{Style.RESET_ALL}: Package names not available on conda-forge"
113113
)
114114
print_msg(
115-
(
116-
f"{Fore.YELLOW}YELLOW{Style.RESET_ALL}: "
117-
"PEP-725 PURLs that did not map to known package"
118-
)
115+
f"{Fore.YELLOW}YELLOW{Style.RESET_ALL}: "
116+
"PEP-725 PURLs that did not map to known package"
119117
)
120118
print_msg(f"{Fore.GREEN}GREEN{Style.RESET_ALL}: Packages available on conda-forge")
121119

grayskull/license/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def get_all_licenses() -> List:
1111
full_path = os.path.join(data_folder, license_file)
1212
if not os.path.isfile(full_path) or license_file.endswith(".py"):
1313
continue
14-
with open(full_path, "r") as f:
14+
with open(full_path) as f:
1515
all_licenses.append((license_file, f.read()))
1616
return all_licenses

grayskull/license/discovery.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def get_opensource_license(license_spdx: str) -> dict:
208208

209209

210210
def read_licence_cache():
211-
with open(Path(__file__).parent / "licence_cache.json", "r") as licence_cache:
211+
with open(Path(__file__).parent / "licence_cache.json") as licence_cache:
212212
return json.load(licence_cache)
213213

214214

@@ -421,7 +421,7 @@ def get_license_type(path_license: str, default: Optional[str] = None) -> Option
421421
:param default: Default value for the license type
422422
:return: License type
423423
"""
424-
with open(path_license, "r", errors="ignore") as license_file:
424+
with open(path_license, errors="ignore") as license_file:
425425
license_content = license_file.read()
426426
find_apache = re.findall(
427427
r"apache\.org\/licenses\/LICENSE\-([0-9])\.([0-9])",

0 commit comments

Comments
 (0)