Skip to content

Commit

Permalink
Merge pull request #74 from scottwernervt/73/refactor/tox-pyproject-d…
Browse files Browse the repository at this point in the history
…ependencies
  • Loading branch information
scottwernervt authored Jan 21, 2021
2 parents 8972fc2 + 7c17ed1 commit 1626ebc
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 79 deletions.
14 changes: 11 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-ast
- id: check-toml
- id: sort-simple-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies: ["flake8-bugbear==20.1.4"]
additional_dependencies: ["flake8-bugbear==20.11.1"]
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
include:
- { name: 'check', python: '3.7', env: TOXENV=check }
- { name: 'lint', python: '3.7', env: TOXENV=lint }
- { name: 'py35', python: '3.5', env: TOXENV=py35 }
- { name: 'py36', python: '3.6', env: TOXENV=py36 }
- { name: 'py37', python: '3.7', env: TOXENV=py37 }
- { name: 'py38', python: '3.8', env: TOXENV=py38 }
- { name: 'py39', python: '3.9', env: TOXENV=py39 }
- { name: 'docs', python: '3.7', env: TOXENV=docs }

after_failure:
Expand All @@ -31,4 +31,4 @@ after_failure:
notifications:
email:
on_success: never
on_failure: always
on_failure: always
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ Other
0.1 (2017-04-20)
++++++++++++++++

* First release.
* First release.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ recursive-exclude docs *.pyo
recursive-exclude tests *.pyc
recursive-exclude tests *.pyo

prune dist/docs
prune dist/docs
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.. _changelog:

.. include:: ../CHANGELOG.rst
.. include:: ../CHANGELOG.rst
2 changes: 1 addition & 1 deletion docs/supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Do not see your provider? Create an issue and vote for at `cloudstorage issues
.. _`Minio Cloud Storage`: https://www.minio.io/
.. _`Rackspace CloudFiles`: https://www.rackspace.com/cloud/files
.. _B2TODO: https://github.com/scottwernervt/cloudstorage/issues/2
.. _MSTODO: https://github.com/scottwernervt/cloudstorage/issues/1
.. _MSTODO: https://github.com/scottwernervt/cloudstorage/issues/1
50 changes: 49 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,54 @@
[build-system]
requires = ["setuptools>=35.0.2", "wheel>=0.29.0"]
build-backend = "setuptools.build_meta"

[tool.tox]
legacy_tox_ini = """
[tox]
envlist =
check
lint
py36
py37
py38
py39
docs
[testenv]
extras =
tests
amazon
google
local
microsoft
minio
rackspace
passenv = *
commands = pytest {posargs}
[testenv:check]
extras =
check
commands =
python setup.py check --strict --metadata --restructuredtext
check-manifest -v
[testenv:lint]
extras =
lint
commands =
pre-commit run --all-files
[testenv:docs]
deps = -rdocs/requirements.txt
commands =
sphinx-build docs/ dist/docs {posargs}
sphinx-build -b linkcheck docs dist/docs
"""

[tool.black]
line-length = 88
target-version = ["py35", "py36", "py37", "py38"]
target-version = ["py36", "py37", "py38"]
include = '\.pyi?$'
exclude = '''
/(
Expand Down
29 changes: 18 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@
"xattr>=0.9.6; sys_platform != 'win32'",
],
"microsoft": ["azure==4.0.0"],
"minio": ["minio>=4.0.0"],
"minio": ["minio==4.0.0"],
"rackspace": ["openstacksdk<=0.17.2", "rackspacesdk==0.7.5", "requests>=2.19.1"],
"tests": ["flake8", "pytest", "prettyconf", "requests>=2.19.1"],
"tests": ["flake8==3.8.4", "pytest==6.2.1", "prettyconf", "requests>=2.19.1"],
"lint": [
"black==19.10b0",
"flake8==3.7.9",
"flake8-bugbear==20.1.4",
"pre-commit~=2.0",
"black==20.8b1",
"flake8==3.8.4",
"flake8-bugbear==20.11.1",
"pre-commit==2.9.3",
],
"check": [
"docutils==0.16",
"check-manifest==0.46",
"readme-renderer==28.0",
"pygments==2.7.4",
],
"docs": [
"sphinx==3.0.2",
"sphinx_rtd_theme==0.4.3",
"sphinx_autodoc_typehints==1.10.3",
"pygments==2.6.1",
"sphinx==3.4.3",
"sphinx_rtd_theme==0.5.1",
"sphinx_autodoc_typehints==1.11.1",
"pygments==2.7.4",
],
}
EXTRAS_REQUIRE["dev"] = EXTRAS_REQUIRE["tests"] + EXTRAS_REQUIRE["lint"] + ["tox"]
Expand Down Expand Up @@ -93,9 +99,10 @@ def find_version(fname):
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Internet",
"Topic :: Software Development :: Libraries :: Python Modules",
],
Expand Down
3 changes: 1 addition & 2 deletions src/cloudstorage/drivers/digitalocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def _create_bucket_params(self, params: Dict[Any, Any]) -> Dict[Any, Any]:

@property
def regions(self) -> List[str]:
"""List of DigitalOcean regions that support Spaces.
"""
"""List of DigitalOcean regions that support Spaces."""
return ["nyc3", "ams3", "sfo2", "sgp1", "fra1"]

# noinspection PyUnresolvedReferences
Expand Down
2 changes: 1 addition & 1 deletion src/cloudstorage/drivers/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def upload_blob(
base_path = os.path.dirname(blob_path)
self._make_path(base_path)

tmp_blob_path = f'{blob_path}.tmp'
tmp_blob_path = f"{blob_path}.tmp"

with lock_local_file(blob_path):
if isinstance(filename, str):
Expand Down
4 changes: 3 additions & 1 deletion src/cloudstorage/drivers/microsoft.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ def delete_container(self, container: Container) -> None:
def container_cdn_url(self, container: Container) -> str:
azure_container = self._get_azure_container(container.name)
url = "{}://{}/{}".format(
self.service.protocol, self.service.primary_endpoint, azure_container.name,
self.service.protocol,
self.service.primary_endpoint,
azure_container.name,
)
return url

Expand Down
2 changes: 1 addition & 1 deletion src/cloudstorage/drivers/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(
key: str,
secret: str = None,
region: str = "us-east-1",
**kwargs: Dict
**kwargs: Dict,
) -> None:
secure = kwargs.pop("secure", True)
http_client = kwargs.pop("http_client", None)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def binary_stream(binary_filename):
@pytest.fixture(scope="function")
def binary_bytes():
f = io.BytesIO()
f.write(b'1' * 1024 * 1024 * 10)
f.write(b"1" * 1024 * 1024 * 10)
f.seek(0)
yield f

Expand Down
2 changes: 1 addition & 1 deletion tests/data/flask.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The Flask logo is available for download and use in the formats below. You can use the logo to promote Flask like you want. The image is licensed under the “Flask Artwork License”. Read license text.
The Flask logo is available for download and use in the formats below. You can use the logo to promote Flask like you want. The image is licensed under the “Flask Artwork License”. Read license text.
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
TEXT_FILENAME = "flask.txt"
TEXT_STREAM_FILENAME = "flask-stream.txt"
TEXT_FORM_FILENAME = "flask-form.txt"
TEXT_MD5_CHECKSUM = "2a5a634f5c8d931350e83e41c9b3b0bb"
TEXT_MD5_CHECKSUM = "5a9b3669e3a17311e9135fe65e0877a8"

BINARY_FILENAME = "avatar.png"
BINARY_FORM_FILENAME = "avatar-form.png"
Expand Down
9 changes: 3 additions & 6 deletions tests/test_drivers_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,24 +187,21 @@ def test_blob_upload_stream(container, binary_stream):


def test_blob_upload_stream_interrupted(container, binary_bytes):
BLOB_NAME = 'data.bin'
BLOB_NAME = "data.bin"
md5 = hashlib.md5()
md5.update(binary_bytes.getbuffer())
mk5_checksum = md5.hexdigest()

def _upload():
container.upload_blob(
filename=binary_bytes,
blob_name=BLOB_NAME
)
container.upload_blob(filename=binary_bytes, blob_name=BLOB_NAME)

p = mp.Process(target=_upload)
p.start()
time.sleep(0.01)
os.kill(p.pid, 9)
p.join()

bad_blob = container.get_blob(BLOB_NAME + '.tmp')
bad_blob = container.get_blob(BLOB_NAME + ".tmp")
assert bad_blob.checksum != mk5_checksum
bad_blob.delete()

Expand Down
43 changes: 0 additions & 43 deletions tox.ini

This file was deleted.

0 comments on commit 1626ebc

Please sign in to comment.