Skip to content

Commit

Permalink
style: ruff linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
StijnCaerts committed Apr 22, 2024
1 parent fe6fefb commit 53cccb4
Show file tree
Hide file tree
Showing 15 changed files with 930 additions and 446 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.6
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
29 changes: 15 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

import os
import sys
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../'))

sys.path.insert(0, os.path.abspath("."))
sys.path.insert(0, os.path.abspath("../"))


# -- Project information -----------------------------------------------------
import terracatalogueclient
import terracatalogueclient # noqa

project = "TerraCatalogue client"
copyright = terracatalogueclient.__author__
Expand All @@ -40,34 +41,34 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'enum_tools.autoenum',
'sphinx_autodoc_typehints',
'sphinx.ext.viewcode',
'sphinx_copybutton',
'sphinx_design'
"sphinx.ext.autodoc",
"enum_tools.autoenum",
"sphinx_autodoc_typehints",
"sphinx.ext.viewcode",
"sphinx_copybutton",
"sphinx_design",
]

autodoc_preserve_defaults = True
autoclass_content = 'both'
autoclass_content = "both"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'furo'
html_theme = "furo"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
20 changes: 14 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from setuptools import setup, find_packages
import re

with open('terracatalogueclient/__init__.py', 'r') as fd:
__version__ = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
fd.read(), re.MULTILINE).group(1)
with open("terracatalogueclient/__init__.py", "r") as fd:
__version__ = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE
).group(1)

version = __version__

Expand All @@ -16,11 +17,18 @@
url="https://github.com/VITObelgium/terracatalogueclient",
packages=find_packages(),
package_data={"": ["resources/*"]},
install_requires=["requests", "requests-auth~=6.0", "shapely", "humanfriendly", "boto3"],
install_requires=[
"requests",
"requests-auth~=6.0",
"shapely",
"humanfriendly",
"boto3",
],
test_suite="tests",
tests_require=["pytest"],
setup_requires=["pytest-runner"],
extras_require={
"docs": ["sphinx", "sphinx-autodoc-typehints"]
}
"docs": ["sphinx", "sphinx-autodoc-typehints"],
"dev": ["pre-commit", "ruff"],
},
)
10 changes: 9 additions & 1 deletion terracatalogueclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
__version__ = "0.1.17"
__author__ = "Stijn Caerts"

from terracatalogueclient.client import Catalogue, Collection, Product, ProductFile, ProductFileType
from terracatalogueclient.client import (
Catalogue,
Collection,
Product,
ProductFile,
ProductFileType,
)

__all__ = ["Catalogue", "Collection", "Product", "ProductFile", "ProductFileType"]
21 changes: 16 additions & 5 deletions terracatalogueclient/auth.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
from requests_auth import OAuth2AuthorizationCodePKCE, OAuth2ResourceOwnerPasswordCredentials
from requests_auth import (
OAuth2AuthorizationCodePKCE,
OAuth2ResourceOwnerPasswordCredentials,
)


def resource_owner_password_credentials_grant(
username: str, password: str, client_id: str, client_secret: str, token_url: str
username: str, password: str, client_id: str, client_secret: str, token_url: str
) -> OAuth2ResourceOwnerPasswordCredentials:
auth = OAuth2ResourceOwnerPasswordCredentials(token_url=token_url, username=username, password=password, client_id=client_id, client_secret=client_secret)
auth = OAuth2ResourceOwnerPasswordCredentials(
token_url=token_url,
username=username,
password=password,
client_id=client_id,
client_secret=client_secret,
)
# explicitly remove authorization header from request, otherwise both the header and body contain authorization
# information causing the request to WekEO WSO2 IdP (as used in HRVPP project) to fail with a 400 error (bad request)
auth.session.auth = None
return auth


def authorization_code_grant(
authorization_url: str, token_url: str, client_id: str
authorization_url: str, token_url: str, client_id: str
) -> OAuth2AuthorizationCodePKCE:
return OAuth2AuthorizationCodePKCE(authorization_url=authorization_url, token_url=token_url, client_id=client_id)
return OAuth2AuthorizationCodePKCE(
authorization_url=authorization_url, token_url=token_url, client_id=client_id
)
Loading

0 comments on commit 53cccb4

Please sign in to comment.