Skip to content

Commit

Permalink
Improve MissingSettingError's style
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanofusai committed Jun 19, 2024
1 parent 1e62e7a commit 54e2cf7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "scrapy-influxdb-exporter"
version = "1.1.1"
version = "1.1.2"
authors = [{ "name" = "Stefano Fusai", "email" = "[email protected]" }]
description = "A simple package to export Scrapy spider stats to InfluxDB"
readme = "README.md"
Expand Down
9 changes: 2 additions & 7 deletions src/scrapy_influxdb_exporter/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
class SettingMissingError(Exception):
class MissingSettingError(Exception):
"""Raised when a required setting is missing."""

def __init__(self, setting: str) -> None:
"""Construct an instance of the SettingMissingError class.
:param setting: The name of the missing setting.
:type setting: str
"""
def __init__(self, setting: str) -> None: # noqa: D107
super().__init__(f"{setting} setting is missing")
6 changes: 3 additions & 3 deletions src/scrapy_influxdb_exporter/statscollectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from scrapy.crawler import Crawler
from scrapy.statscollectors import StatsCollector, StatsT

from .exceptions import SettingMissingError
from .exceptions import MissingSettingError


class InfluxDBStatsCollector(StatsCollector):
Expand Down Expand Up @@ -37,14 +37,14 @@ def _get_setting(self, name: str) -> str:
:param name: The name of the setting.
:type name: str
:raises SettingMissingError: If the setting is missing.
:raises MissingSettingError: If the setting is missing.
:return: The value of the setting.
:rtype: str
"""
setting = self.crawler.settings.get(name)

if setting is None:
raise SettingMissingError(name)
raise MissingSettingError(name)

return setting

Expand Down

0 comments on commit 54e2cf7

Please sign in to comment.