Skip to content

Commit

Permalink
Remove Black
Browse files Browse the repository at this point in the history
Add pre-commit exclusions
Fix formatting
Update pre-commit plugins
  • Loading branch information
mcarans committed Feb 5, 2024
1 parent 292aa4c commit 8703d23
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 61 deletions.
2 changes: 0 additions & 2 deletions .config/black.toml

This file was deleted.

22 changes: 11 additions & 11 deletions .config/pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: test_loader.py
- id: end-of-file-fixer
exclude: test_csv_processing_blanks.csv
exclude: (test_csv_processing_blanks.csv|test.txt)
- id: check-ast
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
args: [--config, .config/black.toml]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.267
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
# Run the linter.
- id: ruff
args: [--config, .config/ruff.toml, --fix, --exit-non-zero-on-fix]
args: [--config, .config/ruff.toml, --fix]
# Run the formatter.
- id: ruff-format
args: [--config, .config/ruff.toml]
- repo: https://github.com/jazzband/pip-tools
rev: 6.13.0
rev: 7.3.0
hooks:
- id: pip-compile
name: pip-compile requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion .config/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ exclude = ["_version.py"]
ignore = [
"E501" # Line too long
]
# List of rules: https://beta.ruff.rs/docs/rules/
# List of rules: https://docs.astral.sh/ruff/rules/
select = [
"E", # pycodestyle - default
"F", # pyflakes - default
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ you make a git commit:
pre-commit install

The configuration file for this project is in a
non-start location. Thus, you will need to edit your
non-standard location. Thus, you will need to edit your
`.git/hooks/pre-commit` file to reflect this. Change
the line that begins with `ARGS` to:

ARGS=(hook-impl --config=.config/pre-commit-config.yaml --hook-type=pre-commit)

With pre-commit, all code is formatted according to
[black]("https://github.com/psf/black") and
[ruff]("https://github.com/charliermarsh/ruff") guidelines.

To check if your changes pass pre-commit without committing, run:
Expand All @@ -41,7 +40,7 @@ To run the tests and view coverage, execute:

pytest -c .config/pytest.ini --cov hdx --cov-config .config/coveragerc

Follow the example set out already in ``api.rst`` as you write the documentation.
Follow the example set out already in ``documentation/main.md`` as you write the documentation.

## Packages

Expand Down
14 changes: 3 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,10 @@ python = ["3.11"]

[tool.hatch.envs.lint]
detached = true
dependencies = [
"black",
"ruff",
]
dependencies = ["ruff"]

[tool.hatch.envs.lint.scripts]
style = [
"ruff --config .config/ruff.toml {args:.}",
"black --config .config/black.toml --check --diff {args:.}",
]
# Not used for anything at the moment
fmt = [
"black --config .config/black.toml {args:.}",
"ruff --config .config/ruff.toml --fix {args:.}",
"ruff check --config .config/ruff.toml --diff {args:.}",
"ruff format --config .config/ruff.toml --diff {args:.}",
]
43 changes: 23 additions & 20 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# This file is autogenerated by pip-compile with Python 3.11
# by the following command:
#
# pip-compile --all-extras --output-file=requirements.txt --resolver=backtracking pyproject.toml
# pip-compile --all-extras --output-file=requirements.txt pyproject.toml
#
annotated-types==0.6.0
# via pydantic
attrs==23.1.0
attrs==23.2.0
# via
# frictionless
# jsonlines
# jsonschema
beautifulsoup4==4.12.2
beautifulsoup4==4.12.3
# via hdx-python-utilities (pyproject.toml)
certifi==2023.11.17
certifi==2024.2.2
# via requests
cfgv==3.4.0
# via pre-commit
Expand All @@ -25,19 +25,21 @@ click==8.1.7
# via typer
colorama==0.4.6
# via typer
coverage[toml]==7.3.2
# via pytest-cov
coverage[toml]==7.4.1
# via
# coverage
# pytest-cov
distlib==0.3.8
# via virtualenv
dnspython==2.4.2
dnspython==2.5.0
# via email-validator
email-validator==2.1.0.post1
# via hdx-python-utilities (pyproject.toml)
et-xmlfile==1.1.0
# via openpyxl
filelock==3.13.1
# via virtualenv
frictionless==5.16.0
frictionless==5.16.1
# via hdx-python-utilities (pyproject.toml)
html5lib==1.1
# via hdx-python-utilities (pyproject.toml)
Expand All @@ -55,7 +57,7 @@ iniconfig==2.0.0
# via pytest
isodate==0.6.1
# via frictionless
jinja2==3.1.2
jinja2==3.1.3
# via frictionless
jsonlines==4.0.0
# via hdx-python-utilities (pyproject.toml)
Expand All @@ -71,7 +73,7 @@ markdown-it-py==3.0.0
# via rich
marko==2.0.2
# via frictionless
markupsafe==2.1.3
markupsafe==2.1.5
# via jinja2
mdurl==0.1.2
# via markdown-it-py
Expand All @@ -83,21 +85,21 @@ packaging==23.2
# via pytest
petl==1.7.14
# via frictionless
platformdirs==4.1.0
platformdirs==4.2.0
# via virtualenv
pluggy==1.3.0
pluggy==1.4.0
# via pytest
pre-commit==3.6.0
# via hdx-python-utilities (pyproject.toml)
pydantic==2.5.2
pydantic==2.6.1
# via frictionless
pydantic-core==2.14.5
pydantic-core==2.16.2
# via pydantic
pygments==2.17.2
# via rich
pyrsistent==0.20.0
# via jsonschema
pytest==7.4.3
pytest==8.0.0
# via
# hdx-python-utilities (pyproject.toml)
# pytest-cov
Expand All @@ -110,7 +112,7 @@ python-dateutil==2.8.2
# via
# frictionless
# hdx-python-utilities (pyproject.toml)
python-slugify==8.0.1
python-slugify==8.0.3
# via frictionless
pyyaml==6.0.1
# via
Expand All @@ -123,7 +125,7 @@ requests==2.31.0
# via
# frictionless
# requests-file
requests-file==1.5.1
requests-file==2.0.0
# via hdx-python-utilities (pyproject.toml)
rfc3986==2.0.0
# via frictionless
Expand All @@ -142,7 +144,6 @@ six==1.16.0
# html5lib
# isodate
# python-dateutil
# requests-file
soupsieve==2.5
# via beautifulsoup4
stringcase==1.2.0
Expand All @@ -154,14 +155,16 @@ tabulate==0.9.0
text-unidecode==1.3
# via python-slugify
typer[all]==0.9.0
# via frictionless
# via
# frictionless
# typer
typing-extensions==4.9.0
# via
# frictionless
# pydantic
# pydantic-core
# typer
urllib3==2.1.0
urllib3==2.2.0
# via requests
validators==0.22.0
# via frictionless
Expand Down
2 changes: 1 addition & 1 deletion src/hdx/utilities/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def close(self) -> None:

@staticmethod
def get_normalised_emails(
recipients: Union[str, ListTuple[str]]
recipients: Union[str, ListTuple[str]],
) -> List[str]:
"""Get list of normalised emails.
Expand Down
30 changes: 18 additions & 12 deletions tests/hdx/utilities/test_dateparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,32 @@ def test_now_utc(self):
)

def test_parse_date_range(self):
result = datetime(2013, 2, 10, 0, 0, tzinfo=timezone.utc), datetime(
2013, 2, 10, 0, 0, tzinfo=timezone.utc
result = (
datetime(2013, 2, 10, 0, 0, tzinfo=timezone.utc),
datetime(2013, 2, 10, 0, 0, tzinfo=timezone.utc),
)
assert parse_date_range("10/02/2013") == result
assert parse_date_range("2013/02/10") == result
result = datetime(2013, 2, 20, 10, 0, tzinfo=timezone.utc), datetime(
2013, 2, 20, 10, 0, tzinfo=timezone.utc
result = (
datetime(2013, 2, 20, 10, 0, tzinfo=timezone.utc),
datetime(2013, 2, 20, 10, 0, tzinfo=timezone.utc),
)
assert parse_date_range("20/02/2013 10:00:00") == result
assert (
parse_date_range("20/02/2013 10:00:00", "%d/%m/%Y %H:%M:%S")
== result
)
result = datetime(2013, 2, 20, 0, 0, tzinfo=timezone.utc), datetime(
2013, 2, 20, 0, 0, tzinfo=timezone.utc
result = (
datetime(2013, 2, 20, 0, 0, tzinfo=timezone.utc),
datetime(2013, 2, 20, 0, 0, tzinfo=timezone.utc),
)
assert parse_date_range("20/02/2013") == result
assert (
parse_date_range("20/02/2013 10:00:00", zero_time=True) == result
)
result2 = datetime(2013, 2, 20, 0, 0, tzinfo=timezone.utc), datetime(
2013, 2, 20, 23, 59, 59, tzinfo=timezone.utc
result2 = (
datetime(2013, 2, 20, 0, 0, tzinfo=timezone.utc),
datetime(2013, 2, 20, 23, 59, 59, tzinfo=timezone.utc),
)
assert (
parse_date_range(
Expand Down Expand Up @@ -103,8 +107,9 @@ def test_parse_date_range(self):
)
fuzzyresult["nondate"] = None
assert fuzzy == fuzzyresult
result = datetime(2013, 2, 1, 0, 0, tzinfo=timezone.utc), datetime(
2013, 2, 28, 0, 0, tzinfo=timezone.utc
result = (
datetime(2013, 2, 1, 0, 0, tzinfo=timezone.utc),
datetime(2013, 2, 28, 0, 0, tzinfo=timezone.utc),
)
assert parse_date_range("02/2013") == result
assert parse_date_range("02/2013", "%m/%Y") == result
Expand All @@ -119,8 +124,9 @@ def test_parse_date_range(self):
"nondate": ("date is ", " for this test"),
"date": ("02/2013",),
}
result = datetime(2013, 1, 1, 0, 0, tzinfo=timezone.utc), datetime(
2013, 12, 31, 0, 0, tzinfo=timezone.utc
result = (
datetime(2013, 1, 1, 0, 0, tzinfo=timezone.utc),
datetime(2013, 12, 31, 0, 0, tzinfo=timezone.utc),
)
assert parse_date_range("2013") == result
assert parse_date_range("2013", "%Y") == result
Expand Down

0 comments on commit 8703d23

Please sign in to comment.