Skip to content

Commit

Permalink
Merge pull request #95 from aiven/sgiffard/BF-1560_add_typing/base
Browse files Browse the repository at this point in the history
Base code to add `mypy` support [BF-1560]

#95
  • Loading branch information
aris-aiven authored Mar 16, 2023
2 parents 305df9d + a4f67c2 commit d91d6f0
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 45 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ pglookout.egg-info/
coverage.xml
/pglookout/version.py
*.swp
.hypothesis/

.idea/
rpm/
dist/

# Generated targets
pglookout-rpm-src.tar
39 changes: 0 additions & 39 deletions .pylintrc

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2023 Aiven Oy and Ohmu Ltd and pglookout project contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
short_ver = 2.0.2
short_ver = 2.0.3
long_ver = $(shell git describe --long 2>/dev/null || echo $(short_ver)-0-unknown-g`git describe --always`)
generated = pglookout/version.py

Expand All @@ -11,16 +11,19 @@ all: $(generated)
pglookout/version.py: version.py
$(PYTHON) $^ $@

test: flake8 pylint unittest
test: mypy flake8 pylint unittest

unittest: $(generated)
$(PYTHON) -m pytest -vv test/
$(PYTHON) -m pytest

mypy: $(generated)
$(PYTHON) -m mypy

flake8: $(generated)
$(PYTHON) -m flake8 --ignore E722,E203,W503 --max-line-len=125 $(PYTHON_SOURCE_DIRS)
$(PYTHON) -m flake8 $(PYTHON_SOURCE_DIRS)

pylint: $(generated)
$(PYTHON) -m pylint --rcfile .pylintrc $(PYTHON_SOURCE_DIRS)
$(PYTHON) -m pylint $(PYTHON_SOURCE_DIRS)

fmt: $(generated)
isort $(PYTHON_SOURCE_DIRS)
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pglookout DEV
* Various bug fixes and operability improvements
* Testing and CI improvements, moving from Travis to GitHub actions
* Switch to using primary and replica to describe server roles in most places
* Add type hints

pglookout 2.0.0 (2018-10-12)
============================
Expand Down
85 changes: 85 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,88 @@ combine_as_imports = true
profile = "black"
skip_gitignore = true
line_length = 125

[tool.pytest.ini_options]
python_classes = "!TestPG" # Ignore class named `TestPG`.
testpaths = 'test/'
addopts = '-vv'

[tool.flake8]
ignore = [
'E722', # https://www.flake8rules.com/rules/E722.html Do not use bare except, specify exception instead
'E203', # https://www.flake8rules.com/rules/E203.html Whitespace before ':'
'W503', # https://www.flake8rules.com/rules/W503.html Line break occurred before a binary operator
]
max-line-length = 125

[tool.mypy]
strict = true
files = [
'pglookout/',
'test/',
]
exclude = [
# Implementation.
'pglookout/__main__.py',
'pglookout/cluster_monitor.py',
'pglookout/common.py',
'pglookout/current_master.py',
'pglookout/logutil.py',
'pglookout/pglookout.py',
'pglookout/pgutil.py',
'pglookout/statsd.py',
'pglookout/version.py',
'pglookout/webserver.py',
# Tests.
'test/conftest.py',
'test/test_cluster_monitor.py',
'test/test_common.py',
'test/test_lookout.py',
'test/test_pgutil.py',
'test/test_webserver.py',
# Other.
'setup.py',
'version.py',
]


[tool.pylint.'MESSAGES CONTROL']
disable = [
'bad-option-value',
'duplicate-code',
'fixme',
'import-outside-toplevel',
'invalid-name',
'len-as-condition',
'locally-disabled',
'missing-docstring',
'no-else-raise',
'no-else-return',
'no-self-use',
'raise-missing-from',
'too-few-public-methods',
'too-many-ancestors',
'too-many-arguments',
'too-many-boolean-expressions',
'too-many-branches',
'too-many-function-args',
'too-many-instance-attributes',
'too-many-locals',
'too-many-public-methods',
'too-many-statements',
'ungrouped-imports',
'unspecified-encoding',
'wrong-import-order',
'wrong-import-position',
]

[tool.pylint.'FORMAT']
max-line-length = 125
max-module-lines = 1200

[tool.pylint.'REPORTS']
output-format = 'text'
reports = 'no'

[tool.pylint.'TYPECHECK']
extension-pkg-whitelist = 'pydantic'
3 changes: 3 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
black==22.10.0
flake8
flake8-pyproject==1.2.2
isort==5.10.1
mock
mypy==1.1.1
types-psycopg2==2.9.21.8
pylint==2.15.4
pytest

0 comments on commit d91d6f0

Please sign in to comment.