Skip to content

Commit

Permalink
chore: use ruff (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Apr 14, 2024
1 parent 7521ebf commit 09cc886
Show file tree
Hide file tree
Showing 74 changed files with 121 additions and 81 deletions.
24 changes: 10 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,6 @@ repos:
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
language_version: python3
exclude: ^templates/

## If like to embrace black styles even in the docs:
# - repo: https://github.com/asottile/blacken-docs
# rev: v1.9.1
# hooks:
# - id: blacken-docs
# additional_dependencies: [black]

- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
Expand Down Expand Up @@ -77,12 +63,14 @@ repos:
# hooks:
# - id: reorder-python-imports
# args: [--application-directories=.:src]

- repo: https://github.com/hadialqattan/pycln
rev: v2.1.2
hooks:
- id: pycln
args: [--config=pyproject.toml]
exclude: ^templates/

- repo: local
hooks:
- id: pylint
Expand All @@ -92,9 +80,17 @@ repos:
types: [python]
exclude: ^templates/
args: [--disable=use-implicit-booleaness-not-comparison]

- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
args:
- --py38-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
1 change: 1 addition & 0 deletions examples/csvfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the CSV adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/dataframe.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the Pandas adapter.
"""

import pandas as pd

from shillelagh.backends.apsw.db import connect
Expand Down
1 change: 1 addition & 0 deletions examples/datasette.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the Datasette adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/generic_xml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the generic XML.
"""

import sys

from shillelagh.backends.apsw.db import connect
Expand Down
1 change: 1 addition & 0 deletions examples/github.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the GitHub adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/gsheets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the GSheets adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/socrata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the Socrata adapter.
"""

from shillelagh.backends.apsw.db import connect

if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions examples/weatherapi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A simple example showing the WeatherAPI adapter.
"""

import os
import sys
from datetime import datetime, timedelta
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ version_scheme = "no-guess-dev"

[tool.flake8]
max-line-length = 90

[tool.ruff]
exclude = [
"templates",
]
10 changes: 1 addition & 9 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ certifi==2022.6.15
# via requests
charset-normalizer==2.1.0
# via requests
exceptiongroup==1.1.3
# via cattrs
greenlet==2.0.2
# via
# shillelagh
# sqlalchemy
idna==3.3
# via requests
importlib-metadata==6.7.0
# via shillelagh
packaging==23.0
# via shillelagh
platformdirs==3.11.0
Expand All @@ -48,14 +44,10 @@ six==1.16.0
sqlalchemy==1.4.39
# via shillelagh
typing-extensions==4.3.0
# via
# cattrs
# shillelagh
# via shillelagh
url-normalize==1.4.3
# via requests-cache
urllib3==1.26.10
# via
# requests
# requests-cache
zipp==3.15.0
# via importlib-metadata
33 changes: 14 additions & 19 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ cfgv==3.3.1
charset-normalizer==2.1.0
# via requests
click==8.1.3
# via pip-tools
# via
# pip-compile-multi
# pip-tools
codespell==2.1.0
# via shillelagh
coverage[toml]==6.4.2
Expand All @@ -52,10 +54,6 @@ dill==0.3.6
# shillelagh
distlib==0.3.5
# via virtualenv
exceptiongroup==1.0.4
# via
# cattrs
# pytest
filelock==3.7.1
# via virtualenv
freezegun==1.2.1
Expand All @@ -76,8 +74,6 @@ idna==3.3
# via
# requests
# yarl
importlib-metadata==6.7.0
# via shillelagh
iniconfig==1.1.1
# via pytest
isort==5.10.1
Expand Down Expand Up @@ -105,8 +101,12 @@ pandas==1.4.3
# via shillelagh
pep517==0.12.0
# via build
pip-tools==6.8.0
pip-compile-multi==2.6.3
# via shillelagh
pip-tools==6.8.0
# via
# pip-compile-multi
# shillelagh
platformdirs==2.5.2
# via
# pylint
Expand Down Expand Up @@ -173,6 +173,8 @@ requests-mock==1.9.3
# via shillelagh
rsa==4.9
# via google-auth
ruff==0.3.7
# via shillelagh
s3transfer==0.6.0
# via boto3
six==1.16.0
Expand All @@ -193,18 +195,13 @@ tabulate==0.8.9
toml==0.10.2
# via pre-commit
tomli==2.0.1
# via
# build
# coverage
# pylint
# pytest
# via pep517
tomlkit==0.11.1
# via pylint
toposort==1.10
# via pip-compile-multi
typing-extensions==4.3.0
# via
# astroid
# pylint
# shillelagh
# via shillelagh
url-normalize==1.4.3
# via requests-cache
urllib3==1.26.10
Expand All @@ -224,8 +221,6 @@ wrapt==1.14.1
# via astroid
yarl==1.8.1
# via shillelagh
zipp==3.15.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
# pip
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ testing =
pandas>=1.2.2
pip-tools>=6.4.0
pre-commit>=2.13.0
pip-compile-multi>=2.6.3
prison>=0.2.1
prompt_toolkit>=3
psutil>=5.8.0
Expand All @@ -95,6 +96,7 @@ testing =
pytest>=7.2.0
python-jsonpath>=0.10.3
requests-mock>=1.8.0
ruff>=0.3.7
tabulate>=0.8.9
yarl>=1.8.1
all =
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Skeleton ``setup.py``, reads configuration from ``setup.cfg``.
"""

import sys

from pkg_resources import VersionConflict, require
Expand Down
1 change: 0 additions & 1 deletion src/shillelagh/adapters/api/datasette.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def get_field(value: Any) -> Field:


class DatasetteAPI(Adapter):

"""
An adapter to Datasette instances (https://datasette.io/).
"""
Expand Down
1 change: 0 additions & 1 deletion src/shillelagh/adapters/api/generic_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@


class GenericJSONAPI(Adapter):

"""
An adapter for fetching JSON data.
"""
Expand Down
1 change: 0 additions & 1 deletion src/shillelagh/adapters/api/generic_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def element_to_dict(element: ET.Element) -> Any:


class GenericXMLAPI(GenericJSONAPI):

"""
An adapter for fetching XML data.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/shillelagh/adapters/api/github.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
An adapter for GitHub.
"""

import json
import logging
import urllib.parse
Expand Down Expand Up @@ -101,7 +102,6 @@ class Column:


class GitHubAPI(Adapter):

"""
An adapter for GitHub.
"""
Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
Google Sheets adapter.
"""

import datetime
import json
import logging
Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Custom fields for the GSheets adapter.
"""

import datetime
from typing import Any, List, Optional, Type, Union

Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/lib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper functions for the GSheets adapter."""

import datetime
import itertools
import string
Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/parsing/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Token for parsing date and time.
"""

import re
from datetime import date, datetime, time, timedelta
from typing import Any, Dict, Generic, Iterator, List, Tuple, Type, TypeVar
Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/parsing/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
https://developers.google.com/sheets/api/guides/formats#number_format_tokens
"""

# pylint: disable=c-extension-no-member, broad-exception-raised
import math
import operator
Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Types for the GSheets adapter."""

from enum import Enum


Expand Down
1 change: 1 addition & 0 deletions src/shillelagh/adapters/api/gsheets/typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Custom types for the GSheets adapter."""

from typing import Any, List

from typing_extensions import Literal, TypedDict
Expand Down
1 change: 0 additions & 1 deletion src/shillelagh/adapters/api/html_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class HTMLTableAPI(Adapter):

"""
An adapter for scraping HTML tables.
"""
Expand Down
Loading

0 comments on commit 09cc886

Please sign in to comment.