Skip to content

Update validations #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:
# manually triggered

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: make env
- name: Lint with pylint
run: make pylint
- name: Test with pytest
run: make test
- name: Documentation
run: make doc
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[MESSAGES CONTROL]
disable=R,attribute-defined-outside-init,bad-continuation,bad-option-value,bare-except,invalid-name,locally-disabled,missing-docstring,redefined-builtin,ungrouped-imports,wrong-import-order,wrong-import-position
disable=R,attribute-defined-outside-init,bad-continuation,bad-option-value,bare-except,invalid-name,locally-disabled,missing-docstring,redefined-builtin,ungrouped-imports,wrong-import-order,wrong-import-position,superfluous-parens

[REPORTS]
reports=no
Expand Down
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

11 changes: 7 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
default: test

test: env
.env/bin/py.test -x tests --cov=backslash --cov-report=html
.env/bin/pytest -x tests --cov=backslash --cov-report=html

pylint: env
.env/bin/pylint --rcfile .pylintrc backslash tests

doc: env
.env/bin/python setup.py build_sphinx -a -E
.env/bin/sphinx-build -a -W -E docs build/sphinx/html

env: .env/.up-to-date


.env/.up-to-date: setup.py Makefile setup.cfg
virtualenv --no-site-packages .env
.env/bin/pip install -e .[testing]
python3 -m venv .env
.env/bin/pip install -e .[testing,doc]
touch $@

1 change: 1 addition & 0 deletions backslash/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pylint: disable=unused-argument
#pylint: disable=unused-import
#pylint: disable=exec-used
#pylint: disable=unnecessary-lambda-assignment
import sys
from contextlib import contextmanager

Expand Down
2 changes: 1 addition & 1 deletion backslash/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .utils import raise_for_status, compute_memory_usage
from .warning import Warning

from typing import Optional, Union, Dict, Tuple, Any, Iterator, Type, TYPE_CHECKING
from typing import Optional, Union, Dict, Tuple, Any, Iterator, TYPE_CHECKING

if TYPE_CHECKING:
from .client import Backslash
Expand Down
2 changes: 1 addition & 1 deletion backslash/api_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __getattr__(self, name: str) -> Optional[Union[int, str]]:
try:
return self.__dict__['_data'][name]
except KeyError:
raise AttributeError(name)
raise AttributeError(name) from None

def refresh(self):
prev_id = self.id
Expand Down
11 changes: 6 additions & 5 deletions backslash/contrib/slash_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

try:
import git
except Exception as e: # pylint: disable=broad-except
except Exception: # pylint: disable=broad-except
pass

import slash
Expand All @@ -38,6 +38,7 @@
from ..__version__ import __version__ as BACKSLASH_CLIENT_VERSION

_DEFAULT_CONFIG_FILENAME = os.path.expanduser('~/.backslash/config.json')
_GET_TOKEN_TIMEOUT_SEC = 30

_logger = logbook.Logger(__name__)

Expand Down Expand Up @@ -388,7 +389,7 @@ def _calculate_file_hash(self, filename):
returned = self._file_hash_cache.get(filename)
if returned is None:
try:
with open(filename, 'rb') as f:
with open(filename, 'rb', encoding='utf-8') as f:
data = f.read()
h = hashlib.sha1()
h.update('blob '.encode('utf-8'))
Expand Down Expand Up @@ -561,7 +562,7 @@ def _get_existing_tokens(self):
def _get_config(self):
if not os.path.isfile(self._config_filename):
return {}
with open(self._config_filename) as f:
with open(self._config_filename, encoding='utf-8') as f:
return json.load(f)

def _save_token(self, token):
Expand All @@ -571,7 +572,7 @@ def _save_token(self, token):

ensure_dir(os.path.dirname(tmp_filename))

with open(tmp_filename, 'w') as f:
with open(tmp_filename, 'w', encoding='utf-8') as f:
json.dump(cfg, f, indent=2)
os.rename(tmp_filename, self._config_filename)

Expand Down Expand Up @@ -611,7 +612,7 @@ def _fetch_token_via_browser(self):
opened_browser = False
url = self._get_token_request_url()
for retry in itertools.count():
resp = requests.get(url)
resp = requests.get(url, timeout=_GET_TOKEN_TIMEOUT_SEC)
resp.raise_for_status()
data = resp.json()
if retry == 0:
Expand Down
2 changes: 1 addition & 1 deletion backslash/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def raise_for_status(resp: Response) -> None:
except HTTPError as e:
raise HTTPError(
f'{e.response.request.method} {e.response.request.url}: {e.response.status_code}\n\n{e.response.content}',
response=resp, request=resp.request)
response=resp, request=resp.request) from None
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
#language = None

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
3 changes: 0 additions & 3 deletions docs/requirements.txt

This file was deleted.

7 changes: 6 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ testing =
slash>=1.5.0
Flask
Flask-Loopback
pylint~=2.2.0
pylint
pytest>4.0
pytest-cov>=2.6
URLObject
weber-utils

doc =
alabaster
releases
Sphinx

sentry =
raven

Expand Down
2 changes: 1 addition & 1 deletion tests/test_backslash.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# py.test style tests here

def test_import():
import backslash # pylint: disable=trailing-newlines, unused-variable, unused-import
import backslash # pylint: disable=unused-import, import-outside-toplevel
4 changes: 2 additions & 2 deletions tests/test_slash_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def test_importing_slash_plugin():
from backslash.contrib import slash_plugin # pylint: disable=unused-variable,unused-import
from backslash.contrib import slash_plugin # pylint: disable=unused-variable,unused-import,import-outside-toplevel


def test_exception_distilling(traceback):
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_failing():

@pytest.fixture
def installed_plugin(request, server_url):
from backslash.contrib import slash_plugin
from backslash.contrib import slash_plugin # pylint: disable=import-outside-toplevel
plugin = slash_plugin.BackslashPlugin(url=str(server_url), runtoken='blap')

@request.addfinalizer
Expand Down