Skip to content
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

23701 - Format with black and isort - BCOL-API, JOBS, PAY-ADMIN, PAY-QUEUE #1773

Merged
merged 10 commits into from
Oct 8, 2024
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
18 changes: 15 additions & 3 deletions bcol-api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,27 @@ install: clean
#################################################################################
# COMMANDS - CI #
#################################################################################
ci: lint flake8 test ## CI flow
ci: isort-ci black-ci lint flake8 test ## CI flow

isort:
poetry run isort .

isort-ci:
poetry run isort --check .

black: ## Linting with black
poetry run black .

black-ci:
poetry run black --check .

pylint: ## Linting with pylint
poetry run pylint --rcfile=setup.cfg src/$(PROJECT_NAME)
poetry run pylint src/$(PROJECT_NAME)

flake8: ## Linting with flake8
poetry run flake8 src/$(PROJECT_NAME) tests

lint: pylint flake8 ## run all lint type scripts
lint: isort black pylint flake8 ## run all lint type scripts

test: ## Unit testing
poetry run pytest
Expand Down
9 changes: 4 additions & 5 deletions bcol-api/gunicorn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@

import os

workers = int(os.environ.get("GUNICORN_PROCESSES", "1")) # pylint: disable=invalid-name
threads = int(os.environ.get("GUNICORN_THREADS", "1")) # pylint: disable=invalid-name

workers = int(os.environ.get('GUNICORN_PROCESSES', '1')) # pylint: disable=invalid-name
threads = int(os.environ.get('GUNICORN_THREADS', '1')) # pylint: disable=invalid-name

forwarded_allow_ips = '*' # pylint: disable=invalid-name
secure_scheme_headers = {'X-Forwarded-Proto': 'https'} # pylint: disable=invalid-name
forwarded_allow_ips = "*" # pylint: disable=invalid-name
secure_scheme_headers = {"X-Forwarded-Proto": "https"} # pylint: disable=invalid-name
7 changes: 3 additions & 4 deletions bcol-api/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
from bcol_api import create_app
from bcol_api.models import db


APP = create_app()
MIGRATE = Migrate(APP, db)
MANAGER = Manager(APP)

MANAGER.add_command('db', MigrateCommand)
MANAGER.add_command("db", MigrateCommand)

if __name__ == '__main__':
logging.log(logging.INFO, 'Running the Manager')
if __name__ == "__main__":
logging.log(logging.INFO, "Running the Manager")
MANAGER.run()
84 changes: 83 additions & 1 deletion bcol-api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions bcol-api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,129 @@ pylint-flask = "^0.6"
pydocstyle = "^6.3.0"
lovely-pytest-docker = "^0.3.1"
isort = "^5.13.2"
black = "^24.10.0"
flake8-pyproject = "^1.2.3"

[tool.flake8]
ignore = ["F401","E402", "Q000", "E203", "W503"]
exclude = [
".venv",
"./venv",
".git",
".history",
"devops",
"*migrations*",
]
per-file-ignores = [
"__init__.py:F401",
"*.py:B902"
]
max-line-length = 120
docstring-min-length=10
count = true

[tool.zimports]
black-line-length = 120
keep-unused-type-checking = true

[tool.black]
target-version = ["py310", "py311", "py312"]
line-length = 120
include = '\.pyi?$'
extend-exclude = '''
/(
# The following are specific to Black, you probably don't want those.
migrations
| devops
| .history
)/
'''

[tool.isort]
atomic = true
profile = "black"
line_length = 120
skip_gitignore = true
skip_glob = ["migrations", "devops"]

[tool.pylint.main]
fail-under = 10
max-line-length = 120
ignore = [ "migrations", "devops", "tests"]
ignore-patterns = ["^\\.#"]
ignored-modules= ["flask_sqlalchemy", "sqlalchemy", "SQLAlchemy" , "alembic", "scoped_session"]
ignored-classes= "scoped_session"
ignore-long-lines = "^\\s*(# )?<?https?://\\S+>?$"
extension-pkg-whitelist = "pydantic"
notes = ["FIXME","XXX","TODO"]
overgeneral-exceptions = ["builtins.BaseException", "builtins.Exception"]
confidence = ["HIGH", "CONTROL_FLOW", "INFERENCE", "INFERENCE_FAILURE", "UNDEFINED"]
disable = "C0209,C0301,W0511,W0613,W0703,W1514,W1203,R0801,R0902,R0903,R0911,R0401,R1705,R1718,W3101"
argument-naming-style = "snake_case"
attr-naming-style = "snake_case"
class-attribute-naming-style = "any"
class-const-naming-style = "UPPER_CASE"
class-naming-style = "PascalCase"
const-naming-style = "UPPER_CASE"
function-naming-style = "snake_case"
inlinevar-naming-style = "any"
method-naming-style = "snake_case"
module-naming-style = "any"
variable-naming-style = "snake_case"
docstring-min-length = -1
good-names = ["i", "j", "k", "ex", "Run", "_"]
bad-names = ["foo", "bar", "baz", "toto", "tutu", "tata"]
defining-attr-methods = ["__init__", "__new__", "setUp", "asyncSetUp", "__post_init__"]
exclude-protected = ["_asdict", "_fields", "_replace", "_source", "_make", "os._exit"]
valid-classmethod-first-arg = ["cls"]
valid-metaclass-classmethod-first-arg = ["mcs"]

[tool.pytest.ini_options]
asyncio_mode = "auto"
minversion = "2.0"
testpaths = [
"tests",
]
addopts = "--verbose --strict -p no:warnings --cov=src --cov-report html:htmlcov --cov-report xml:coverage.xml"
python_files = [
"test*.py"
]
norecursedirs = [
".git", ".tox", "venv*", "requirements*", "build",
]
log_cli = true
log_cli_level = "1"
filterwarnings = [
"ignore::UserWarning"
]
markers = [
"slow",
"serial",
]

[tool.coverage.run]
branch = true
source = [
"src/auth_api",
]
omit = [
"wsgi.py",
"gunicorn_config.py"
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"from",
"import",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
'if __name__ == "__main__":',
]

[build-system]
requires = ["poetry-core"]
Expand Down
18 changes: 9 additions & 9 deletions bcol-api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def read_requirements(filename):
:return: Python requirements
:rtype: list
"""
with open(filename, 'r') as req:
with open(filename, "r") as req:
requirements = req.readlines()
install_requires = [r.strip() for r in requirements if r.find('git+') != 0]
install_requires = [r.strip() for r in requirements if r.find("git+") != 0]
return install_requires


Expand All @@ -39,21 +39,21 @@ def read(filepath):
:return: file contents
:rtype: str
"""
with open(filepath, 'r') as file_handle:
with open(filepath, "r") as file_handle:
content = file_handle.read()
return content


REQUIREMENTS = read_requirements('requirements/prod.txt')
REQUIREMENTS = read_requirements("requirements/prod.txt")

setup(
name="bcol_api",
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
packages=find_packages("src"),
package_dir={"": "src"},
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
include_package_data=True,
license=read('LICENSE'),
long_description=read('README.md'),
license=read("LICENSE"),
long_description=read("README.md"),
zip_safe=False,
install_requires=REQUIREMENTS,
setup_requires=["pytest-runner"],
Expand Down
Loading
Loading