Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Ruff tools, update pre-commit #558

Merged
merged 3 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

30 changes: 10 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,31 @@
exclude: docs
repos:
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.6.0]
additional_dependencies: [black==22.12.0]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: check-yaml
exclude: tests
- id: sort-simple-yaml
files: grayskull/pypi/config.yaml
files: config.yaml
- id: check-toml
- id: check-json
- id: check-merge-conflict
- id: pretty-format-json
args: [--autofix]
- id: debug-statements
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
exclude: tests/data
- repo: https://github.com/PyCQA/flake8
rev: 7.1.1
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
hooks:
- id: flake8
exclude: tests/data
language_version: python3
# Run the linter
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
# Run the formatter
- id: ruff-format
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ exclude .github
exclude azure-pipelines.yml
exclude .gitignore
exclude .pre-commit-config.yaml
exclude .flake8
exclude .coveragerc
exclude .isort.cfg
prune tests/
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
2 changes: 1 addition & 1 deletion grayskull/base/track_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def solve_pkg_name(pkg: str, config_file: Union[Path, str]) -> str:
@lru_cache(maxsize=5)
def _get_track_info_from_file(config_file: Union[Path, str]) -> Dict:
yaml = YAML()
with open(config_file, "r", encoding="utf_8") as yaml_file:
with open(config_file, encoding="utf_8") as yaml_file:
return yaml.load(yaml_file)


Expand Down
6 changes: 2 additions & 4 deletions grayskull/cli/stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ def print_req(list_pkg):
f"\n{Fore.RED}RED{Style.RESET_ALL}: Package names not available on conda-forge"
)
print_msg(
(
f"{Fore.YELLOW}YELLOW{Style.RESET_ALL}: "
"PEP-725 PURLs that did not map to known package"
)
f"{Fore.YELLOW}YELLOW{Style.RESET_ALL}: "
"PEP-725 PURLs that did not map to known package"
)
print_msg(f"{Fore.GREEN}GREEN{Style.RESET_ALL}: Packages available on conda-forge")

Expand Down
2 changes: 1 addition & 1 deletion grayskull/license/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def get_all_licenses() -> List:
full_path = os.path.join(data_folder, license_file)
if not os.path.isfile(full_path) or license_file.endswith(".py"):
continue
with open(full_path, "r") as f:
with open(full_path) as f:
all_licenses.append((license_file, f.read()))
return all_licenses
4 changes: 2 additions & 2 deletions grayskull/license/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def get_opensource_license(license_spdx: str) -> dict:


def read_licence_cache():
with open(Path(__file__).parent / "licence_cache.json", "r") as licence_cache:
with open(Path(__file__).parent / "licence_cache.json") as licence_cache:
return json.load(licence_cache)


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