Skip to content

Commit

Permalink
Add Ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Dec 3, 2024
1 parent 26441a3 commit 27631b0
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 27 deletions.
3 changes: 0 additions & 3 deletions custom/.bandit.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions custom/.prospector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ inherits:
- utils:base
- utils:fix
- utils:no-design-checks
- utils:c2cwsgiutils
- duplicated

pylint:
ruff:
disable:
- missing-timeout # Default timeout set by c2cwsgiutils
- D101 # Missing docstring in public class
- D102 # Missing docstring in public method
- D103 # Missing docstring in public function

bandit:
mypy:
options:
config: .bandit.yaml
python_version: '3.10'
2 changes: 1 addition & 1 deletion custom/custom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def main(global_config, **settings):
"""This function returns a Pyramid WSGI application."""
"""Get the Pyramid WSGI application."""
del global_config # Unused.
with Configurator(settings=settings) as config:
config.include("pyramid_mako")
Expand Down
5 changes: 1 addition & 4 deletions custom/custom/scripts/initialize_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@


def setup_models(dbsession):
"""
Add or update models / fixtures in the database.
"""
"""Add or update models / fixtures in the database."""
del dbsession # Unused


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,18 @@ def get_dwell_demographics(self, postal_code: int, date_time: datetime) -> Featu
return self.error
return self.response_to_geojson_result(response.json())

def check_api_error(self, response: Response):
def check_api_error(self, response: Response) -> None:
if response.status_code != 200:
err_code = response.status_code
err_txt = response.text
LOG.warning("External API error (code %s): %s", err_code, err_txt)
self.error = Response(err_txt, status=err_code)
raise ExternalAPIError("External api error")

def limit_query(self):
def limit_query(self) -> None:
"""
Limit amount of allowed queries per day.
[bgerber] It's rude, but we are using my own key !
"""
delta = datetime.now() - self.request_date
Expand Down
60 changes: 51 additions & 9 deletions custom/poetry.lock

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

8 changes: 4 additions & 4 deletions custom/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ custom-initialize-db = "custom.scripts.initialize_db:main"
main = "custom:main"

[tool.poetry.dependencies]
python = ">=3.12,<3.13"
python = ">=3.12,<3.14"
gunicorn = "23.0.0"
plaster-pastedeploy = "1.0.1"
pyramid = "2.0.2"
Expand Down Expand Up @@ -46,9 +46,9 @@ webob = { version = "1.8.9", optional = true }
cryptography = { version = "43.0.3", optional = true }

[tool.poetry.dev-dependencies]
prospector = { version = "1.13.3", extras = ["with_bandit", "with_mypy", "with_pyroma"] }
prospector-profile-utils = "1.12.2"
prospector-profile-duplicated = "1.8.0"
prospector = { version = "1.13.3", extras = ["with_bandit", "with_mypy", "with_pyroma", "with_ruff"] }
prospector-profile-utils = "1.14.0"
prospector-profile-duplicated = "1.8.1"
types-requests = "2.32.0.20241016"
types-oauthlib = "3.2.0.20240806"

Expand Down

0 comments on commit 27631b0

Please sign in to comment.