diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6379b16..ff35bbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,6 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.8 - run: pip install tox - run: tox diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index cf2985e..c0f2c83 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -16,7 +16,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: 3.8 - name: Install Python dependencies run: pip install wheel diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3717085..0174bcc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,9 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. --- +default_language_version: + python: python3.8 + repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.1.0 + rev: v4.5.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -32,15 +35,15 @@ repos: - id: fix-encoding-pragma args: ['--remove'] - repo: https://github.com/pre-commit/mirrors-autopep8 - rev: v1.4.2 + rev: v2.0.4 hooks: - id: autopep8 - - repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 + - repo: https://github.com/PyCQA/flake8 + rev: 6.1.0 hooks: - id: flake8 - repo: https://github.com/asottile/reorder_python_imports - rev: v1.3.2 + rev: v3.12.0 hooks: - id: reorder-python-imports args: [ @@ -48,12 +51,11 @@ repos: '--remove-import', 'from __future__ import unicode_literals', ] - repo: https://github.com/asottile/pyupgrade - rev: v1.9.0 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py3-plus] - repo: https://github.com/asottile/add-trailing-comma - rev: v0.7.1 + rev: v3.1.0 hooks: - id: add-trailing-comma - args: [--py36-plus] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8a2818b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -dist: xenial -branches: - only: - - master - - /^v[0-9.]+$/ - - /^travis-ci-.*$/ -language: python -cache: - pip: true - directories: - - .tox/ - - $HOME/.cache/pip-faster/ - - $HOME/.cache/pre-commit/ -before_cache: - # We don't currently use any secure environment variables, but just in case, and also to avoid caches that grow forever, remove log dirs. - - rm -rf .tox/*/log .tox/log .tox/*/local/log -python: - - "3.6" -env: - - TOXENV=py36,mypy -install: pip install coveralls tox==3.2 tox-pip-extensions==1.3.0 -script: tox -i https://pypi.python.org/simple -after_success: - - coveralls -deploy: - - provider: pypi - user: __token__ - password: - secure: "LQtCil5PBwzlAawj6bD90mxclBLTPZtUolhrOFXAn0VUtMjwYHDHdChZuxgYzWEgE2dlZhAnExPeeCtwlUrISYH8T4VQBar3Cpt/7rTTqVysoEvojV6ENHws4+ESnl4/Mu8CwV9dav+bK0xt1fgrwuhSbzdFHH6+msvi1LaLhBO61IY6dBSFANfmK2uDu/6UJ+tyJ2LQWlg4JqEluNF8eH/I7hGdzpbnG/jKrSk/3XgM1COr137j51GVOtZOmxWF5oTNUbcAnT55DGv3axiLhPcgO/kT6vZyYhEwfkCcu/WIjXXagYWTurXZ9hoegrMiSTwc/Z6UygRoVsK1PFqxLPU8d0JW6QqoevExzJoUCMe77ErUYzqQaUyD5o6kdKGq2U37J6hRHX87hA2zi+0phswt4bKjXLB4vj4nQNwyPy7BQ+2ua/nJd3FJwvomJjBNnLV4sz2qMrODM0yxjULXrnbCPxIF+1MMjxPWMLPUmefCm8Le9k9AyG9A9vdYb//8WMsXeNFEyvwM3zryhBuWb98b7mrcr6MR121M/Q+/3+Y+MaSg7zFwtemJ1cT4us9hDmlUA43TNcLOtOmv7T3Z2YpdJdFIYoKZJjvmmD9ArUa1HAhRX/1v4UWG+EoPC6nv6Faf3kVkztPlpT/bJAem2bpGwewgBoz43MDxv3wO0oE=" - on: - tags: true - repo: Yelp/sticht diff --git a/mypy.ini b/mypy.ini index 31c5d07..b4c531f 100644 --- a/mypy.ini +++ b/mypy.ini @@ -13,7 +13,7 @@ # limitations under the License. [mypy] -python_version = 3.6 +python_version = 3.8 check_untyped_defs = False ignore_missing_imports = True warn_redundant_casts = True diff --git a/requirements-dev.txt b/requirements-dev.txt index f807b93..f9cb69c 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -11,10 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - -# Coverage==5.0 fails with `Safety level may not be changed inside a transaction` -# on python 3.6.0 (xenial) (https://github.com/nedbat/coveragepy/issues/703) -coverage<5.0 +coverage mypy pre-commit>=1.0.0 pytest diff --git a/setup.py b/setup.py index 27f6a5b..baa58bc 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ version='1.1.18', classifiers=[ 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.8', ], install_requires=[ 'pytimeparse', diff --git a/sticht/rollbacks/metrics.py b/sticht/rollbacks/metrics.py index c4f1402..feb5e30 100644 --- a/sticht/rollbacks/metrics.py +++ b/sticht/rollbacks/metrics.py @@ -24,7 +24,7 @@ def _get_metric_configs_for_service_by_cluster( ) -> Dict[str, Dict[str, Any]]: # TODO: add type for rollback file config configs = {} for filename in get_rollback_files_from_soaconfigs(soa_dir, service=service): - with open(filename, 'r') as file: + with open(filename) as file: configs[get_cluster_from_soaconfigs_filename(filename)] = yaml.safe_load(file) return configs diff --git a/sticht/rollbacks/slo.py b/sticht/rollbacks/slo.py index e4f7c13..8b41904 100644 --- a/sticht/rollbacks/slo.py +++ b/sticht/rollbacks/slo.py @@ -75,7 +75,7 @@ def get_slos_for_service(service, soa_dir) -> Generator: for sink in composite_sink.sinks(): if not alert_config_by_ts_metric[ - sink.source.timeseries, sink.source.metric + sink.source.timeseries, sink.source.metric, ].is_silent: signalflow, rules = sink.generate_signalflow_signals_and_rules() query = textwrap.dedent('\n'.join(signalflow)) diff --git a/sticht/slack.py b/sticht/slack.py index 98bbf63..dd6b6b8 100644 --- a/sticht/slack.py +++ b/sticht/slack.py @@ -468,11 +468,13 @@ async def listen_for_slack_events(self): log_error(f'Exception while processing event: {traceback.format_exc()}') log.debug(f'event: {event!r}') except Exception: - log_error('\n'.join( - 'Uncaught error in listen_for_slack_events:', - traceback.format_exc(), - 'Restarting event listener.', - )) + log_error( + '\n'.join( + 'Uncaught error in listen_for_slack_events:', + traceback.format_exc(), + 'Restarting event listener.', + ), + ) await self.listen_for_slack_events() def notify_users(self, message): diff --git a/sticht/state_machine.py b/sticht/state_machine.py index 0d14321..87cc33c 100644 --- a/sticht/state_machine.py +++ b/sticht/state_machine.py @@ -60,7 +60,7 @@ def trigger(self, *args, **kwargs): float ] = None # in normal operation, this will be None, but this lets tests set a max time. - def __init__(self,): + def __init__(self): self.event_loop = asyncio.get_event_loop() self.finished_event = asyncio.Event(loop=self.event_loop) diff --git a/tests/rollbacks/test_metrics.py b/tests/rollbacks/test_metrics.py index 091639a..88d49cf 100644 --- a/tests/rollbacks/test_metrics.py +++ b/tests/rollbacks/test_metrics.py @@ -15,7 +15,7 @@ @mock.patch('sticht.rollbacks.sources.splunk.SplunkMetricWatcher.query') -def test_watch_metrics_for_service_creates_watchers(mock_splunk_metric_watcher_query, tmp_path,): +def test_watch_metrics_for_service_creates_watchers(mock_splunk_metric_watcher_query, tmp_path): service = 'serviceA' soa_dir = tmp_path (soa_dir / service).mkdir() diff --git a/tox.ini b/tox.ini index b4fe207..804dc6c 100644 --- a/tox.ini +++ b/tox.ini @@ -13,14 +13,15 @@ # limitations under the License. [tox] -envlist = py36 -tox_pip_extensions_ext_pip_custom_platform = true -tox_pip_extensions_ext_venv_update = true +envlist = py38 [testenv] -basepython = python3.6 +basepython = python3.8 deps = -rrequirements-dev.txt -passenv = HOME SSH_AUTH_SOCK USER +passenv = + HOME + SSH_AUTH_SOCK + USER commands = coverage erase coverage run -m pytest {posargs:tests}