Skip to content
Snippets Groups Projects
Commit f501be20 authored by Eva Bardou's avatar Eva Bardou :frog: Committed by Yoann Schneider
Browse files

Upgrade `pre-commit` hooks

parent 46693770
No related branches found
No related tags found
1 merge request!11Upgrade `pre-commit` hooks
Pipeline #162761 passed
**.pyc
*.pyc
*.egg-info/
.tox/
*.egg-info
[settings]
# Compatible with black
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 120
default_section = FIRSTPARTY
known_first_party = arkindex_toolbox
known_third_party = setuptools,yaml
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.2
hooks:
- id: isort
- repo: https://github.com/ambv/black
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies:
- 'flake8-coding==1.3.1'
- 'flake8-copyright==0.2.2'
- 'flake8-debugger==3.1.0'
# Run the linter.
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-ast
- id: check-docstring-first
......@@ -31,9 +24,10 @@ repos:
- id: name-tests-test
args: ['--django']
- id: check-json
- id: check-toml
- id: requirements-txt-fixer
- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
rev: v2.2.6
hooks:
- id: codespell
args: ['--write-changes']
......
[tool.ruff]
exclude = [".git", "__pycache__"]
[tool.ruff.lint]
ignore = ["E501"]
select = [
# pycodestyle
"E",
"W",
# Pyflakes
"F",
# Flake8 Debugger
"T1",
# Isort
"I",
# Implicit Optional
"RUF013",
# Invalid pyproject.toml
"RUF200",
# pyupgrade
"UP",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# flake8-use-pathlib
"PTH",
]
[tool.ruff.per-file-ignores]
# Ignore `pytest-composite-assertion` rules of `flake8-pytest-style` linter for non-test files
"teklia_toolbox/**/*.py" = ["PT018"]
[tool.ruff.isort]
known-first-party = ["teklia_toolbox"]
known-third-party = ["pytest", "setuptools"]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os.path
from pathlib import Path
from setuptools import find_packages, setup
def requirements(path):
assert os.path.exists(path), "Missing requirements {}".format(path)
with open(path) as f:
assert path.exists(), f"Missing requirements {path}"
with path.open() as f:
return list(map(str.strip, f.read().splitlines()))
with open("VERSION") as f:
with Path("VERSION").open() as f:
VERSION = f.read()
install_requires = requirements("requirements.txt")
install_requires = requirements(Path("requirements.txt"))
setup(
name="teklia-toolbox",
version=VERSION,
author="Teklia",
author_email="contact@teklia.com",
python_requires=">=3.7",
python_requires=">=3.10",
install_requires=install_requires,
packages=find_packages(),
include_package_data=True,
......
# -*- coding: utf-8 -*-
import json
import os
import sys
......@@ -53,10 +52,10 @@ class ConfigurationError(ValueError):
return json.dumps(self.errors)
def __repr__(self):
return "{}({!s})".format(self.__class__.__name__, self)
return f"{self.__class__.__name__}({self!s})"
class ConfigParser(object):
class ConfigParser:
def __init__(self, allow_extra_keys=True):
"""
:param allow_extra_keys bool: Ignore extra unspecified keys instead
......@@ -126,5 +125,4 @@ class ConfigParser(object):
if not path.is_file() and exist_ok:
# Act like the file is empty
return self.parse_data({})
with open(path) as f:
return self.parse_data(yaml.safe_load(f))
return self.parse_data(yaml.safe_load(path.read_bytes()))
# -*- coding: utf-8 -*-
import datetime
from timeit import default_timer
class Timer(object):
class Timer:
"""
A context manager to help measure execution times
"""
......
# -*- coding: utf-8 -*-
import tempfile
from pathlib import Path
from unittest import TestCase
......
# -*- coding: utf-8 -*-
import time
from teklia_toolbox.time import Timer
def test_timer():
with Timer() as t:
time.sleep(0.05)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment