Skip to content

Commit 60c3547

Browse files
authored
Merge pull request #4 from UCSB-VRL/precommit-config
Precommit config
2 parents 04a15bd + f7b5746 commit 60c3547

27 files changed

Lines changed: 413 additions & 407 deletions

.github/workflows/lint.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/workflows/pre-commit.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Pre-commit Checks
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Python 3.10
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
# Install pre-commit if not already available in your dependencies
26+
pip install pre-commit
27+
# Optionally install your API package dependencies if needed
28+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29+
30+
- name: Run pre-commit checks
31+
run: pre-commit run

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
**/__pycache__/**
22
*.bak
3-
**/.ruff_cache/**
3+
**/.ruff_cache/**

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 23.7.0 # Use the latest stable version available
4+
hooks:
5+
- id: black
6+
language_version: python3
7+
8+
- repo: https://github.com/PyCQA/isort
9+
rev: 5.12.0 # Update as appropriate
10+
hooks:
11+
- id: isort
12+
language_version: python3
13+
14+
# - repo: https://github.com/PyCQA/flake8
15+
# rev: 6.1.0 # Update as needed
16+
# hooks:
17+
# - id: flake8
18+
# additional_dependencies: [flake8-bugbear] # optional extra checks
19+
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v4.6.0 # Update as needed
22+
hooks:
23+
- id: trailing-whitespace
24+
- id: end-of-file-fixer
25+
- id: check-yaml

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
11
# Bisque API for Python 3
22

33
[![Upload Python Package](https://github.com/UCSB-VRL/bqapi/actions/workflows/python-publish.yml/badge.svg)](https://github.com/UCSB-VRL/bqapi/actions/workflows/python-publish.yml)
4+
[![Pre-commit Checks](https://github.com/UCSB-VRL/bqapi/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/UCSB-VRL/bqapi/actions/workflows/pre-commit.yml)
5+
[![PyPI](https://img.shields.io/pypi/v/bqapi-ucsb?style=flat-square)](https://pypi.org/project/bqapi-ucsb/)
6+
[![Documentation](https://img.shields.io/badge/Documentation-View%20here-brightgreen?style=flat-square)](https://bisque.gitbook.io/docs)
7+
[![PyPi Installs](https://pepy.tech/badge/bqapi-ucsb?style=flat-square)](https://pepy.tech/project/bqapi-ucsb)
48

5-
[Full Documentation](https://github.com/UCSB-VRL/bisqueUCSB)
69

7-
For development, follow [this guide](https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3) and [this repo](https://github.com/gmyrianthous/example-publish-pypi).
810

9-
# Installing
11+
## Install
1012
```
1113
pip install bqapi-ucsb
1214
```
1315

14-
[Pypi link](https://pypi.org/project/bqapi-ucsb)
16+
## Usage
1517

16-
# Usage
17-
```python
18-
from bqapi.comm import BQSession
19-
from bqapi.util import fetch_blob
20-
```
18+
### Upload Image
19+
20+
Upload your first image to BisQue using our tutorial!
2121

22-
# Development
22+
[Upload an Image to BisQue](https://bisque.gitbook.io/docs/bisque-api/upload-an-image)
23+
24+
25+
## Development
2326

2427
For development, follow [this guide](https://towardsdatascience.com/how-to-upload-your-python-package-to-pypi-de1b363a1b3) and [this repo](https://github.com/gmyrianthous/example-publish-pypi).
2528

26-
## Added GitHub Action
2729

28-
### Summary
30+
## Contribute
2931

3032
1. Clone repo
3133
2. Make any necessary changes to source code, setup.py, and setup.cfg
@@ -34,4 +36,3 @@ For development, follow [this guide](https://towardsdatascience.com/how-to-uploa
3436
5. Make sure to have PyPi account credentials
3537
6. run `twine upload dist/*` from main folder
3638
7. Enter username and password
37-

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# Follow Flake8's behavior
33
lint.select = ["E", "F", "W", "C90"] # Enables Flake8-compatible rules
44
lint.ignore = [] # Add rules to ignore
5-
line-length = 79
6-
exclude = ["venv", ".git", "__pycache__", "**/tests/**"]
7-
lint.mccabe.max-complexity = 25 # Set your desired threshold
5+
line-length = 79
6+
exclude = ["venv", ".git", "__pycache__", "**/tests/**"]
7+
lint.mccabe.max-complexity = 25 # Set your desired threshold

setup.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
from setuptools import setup, find_packages
2-
1+
from setuptools import find_packages, setup
32

43
setup(
5-
name='bqapi-ucsb',
6-
version='1.0.6',
4+
name="bqapi-ucsb",
5+
version="1.0.6",
76
author="Bisque Team",
8-
author_email='amil@ucsb.edu',
7+
author_email="amil@ucsb.edu",
98
description="""Python API for interacting with BisQue""",
10-
packages=find_packages('src'),
11-
package_dir={'': 'src'},
12-
keywords='API Bisque',
13-
url='https://github.com/UCSB-VRL/bisqueUCSB',
9+
packages=find_packages("src"),
10+
package_dir={"": "src"},
11+
keywords="API Bisque",
12+
url="https://github.com/UCSB-VRL/bisqueUCSB",
1413
install_requires=[
15-
'six', 'lxml', 'requests==2.32.3', 'requests-toolbelt',
16-
],
14+
"six",
15+
"lxml",
16+
"requests==2.32.3",
17+
"requests-toolbelt",
18+
],
1719
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#empty
1+
# empty

src/bqapi/RequestsMonkeyPatch/requests_patch.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,25 @@
77
"""
88

99
import email.utils
10-
1110
# import mimetypes
1211
import warnings
1312

1413
import requests
1514
import requests.packages.urllib3 as urllib3
1615
import six
17-
from .monkeypatch import monkeypatch_method
1816

17+
from .monkeypatch import monkeypatch_method
1918

2019
REQUESTS_V = [int(s) for s in requests.__version__.split(".")]
2120

2221
print(REQUESTS_V)
2322
if REQUESTS_V < [2, 4, 0] or REQUESTS_V > [2, 32, 3]:
24-
warnings.warn("""\
23+
warnings.warn(
24+
"""\
2525
We need to patch requests 2.4.0 up to 2.32.3, make sure your version of
2626
requests needs this patch, greater than 2.4.3 we do not know if this
27-
patch applys.""")
27+
patch applys."""
28+
)
2829
raise ImportError("Requests 2.4.0 to 2.32.3 is required!")
2930
# elif requests_v > [3, 0, 0]:
3031
# #does not require this patch
@@ -46,7 +47,7 @@ def format_header_param(name, value):
4647
The value of the parameter, provided as a unicode string.
4748
"""
4849
if not any(ch in value for ch in '"\\\r\n'):
49-
result = '%s="%s"' % (name, value)
50+
result = '{}="{}"'.format(name, value)
5051
try:
5152
result.encode("ascii")
5253
except UnicodeEncodeError:
@@ -58,7 +59,7 @@ def format_header_param(name, value):
5859
if not six.PY3: # Python 2:
5960
value_encode = value.encode("utf-8")
6061

61-
value = '%s="%s"; %s*=%s' % (
62+
value = '{}="{}"; {}*={}'.format(
6263
name,
6364
value,
6465
name,

src/bqapi/blockable_module.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import sys
21
import collections
3-
4-
from bqapi import BQSession
5-
6-
72
import logging
3+
import sys
84

5+
from bqapi import BQSession
96

107
# logging.basicConfig(filename='BlockableModule.log',level=logging.DEBUG) #!!!
118
log = logging.getLogger("bqapi.blockable_module")
@@ -21,17 +18,13 @@ def main(self, mex_url=None, auth_token=None, bq=None, **kw):
2118

2219
# check for list parameters
2320
params = bq.get_mex_inputs()
24-
if isinstance(params, dict) or not isinstance(
25-
params, collections.Iterable
26-
):
21+
if isinstance(params, dict) or not isinstance(params, collections.Iterable):
2722
params = [params]
2823
# pass values directly as args
2924
for single_params in params:
3025
for param_name in single_params:
3126
if "value" in single_params[param_name]:
32-
single_params[param_name] = single_params[param_name].get(
33-
"value"
34-
)
27+
single_params[param_name] = single_params[param_name].get("value")
3528

3629
# TODO: measure block startup time
3730
self.start_block(bq, params)

0 commit comments

Comments
 (0)