Skip to content

Commit

Permalink
Version 3.18.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mborsetti committed Feb 20, 2024
1 parent 160d8a2 commit 516643e
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 167 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Expand Up @@ -32,6 +32,15 @@ can check out the `wish list <https://github.com/mborsetti/webchanges/blob/main/
Security, in case of vulnerabilities. [triggers a minor patch]
Internals, for changes that don't affect users. [triggers a minor patch]
Version 3.18.1
===================
2024-02-20

Fixed
-----
* Fixed regression whereby configuration key ``empty-diff`` was inadvertently renamed ``empty_diff``.


Version 3.18
===================
2024-02-19
Expand Down Expand Up @@ -284,7 +293,7 @@ Added
file, and the command line arguments ``--database-engine`` and ``--max-snapshots`` are used to override such
settings. See documentation for more information. Suggested by `jprokos <https://github.com/jprokos>`__ in `#43
<https://github.com/mborsetti/webchanges/issues/43>`__.
* New configuration setting ``empty_diff`` within the ``display`` configuration for backwards compatibility only:
* New configuration setting ``empty-diff`` within the ``display`` configuration for backwards compatibility only:
use the ``additions_only`` job directive instead to achieve the same result. Reported by
`bbeevvoo <https://github.com/bbeevvoo>`__ in `#47 <https://github.com/mborsetti/webchanges/issues/47>`__.
* Aliased the command line arguments ``--gc-cache`` with ``--gc-database``, ``--clean-cache`` with ``--clean-database``
Expand Down
19 changes: 1 addition & 18 deletions RELEASE.rst
@@ -1,20 +1,3 @@
Fixed
-----
* Fixed incorrect handling of HTTP client libraries when ``httpx`` is not installed (should graciously fallback to
``requests``). Reported by `drws <https://github.com/drws>`__ as an add-on to `issuse #66
<https://github.com/mborsetti/webchanges/issues/66>`__.

Added
-----
* Job directive ``enabled`` to allow disabling of a job without removing or commenting it in the jobs file (contributed
by `James Hewitt <https://github.com/Jamstah>`__ `upstream <https://github.com/thp/urlwatch/pull/785>`__).
* ``webhook`` reporter has a new ``rich_text`` config option for preformatted rich text for Slack (contributed
by `K̶e̶v̶i̶n̶ <https://github.com/vimagick>`__ `upstream <https://github.com/thp/urlwatch/pull/780>`__).

Changed
-------
* Command line argument ``--errors`` now uses conditional requests to improve speed. Do not use to test newly modified
jobs since websites reporting no changes from the last snapshot stored by **webchanges** are skipped; use
``--test`` instead.
* If the ``simplejson`` library is installed, it will be used instead of the built-in ``json`` module (see
https://stackoverflow.com/questions/712791).
* Fixed regression whereby configuration key ``empty-diff`` was inadvertently renamed ``empty_diff``.
4 changes: 2 additions & 2 deletions docs/configuration.rst
Expand Up @@ -47,12 +47,12 @@ the configuration:
new: true
error: true
unchanged: false
empty_diff: true
empty-diff: true
If you set ``unchanged`` to ``true``, :program:`webchanges` will always report all pages that are checked but have not
changed.

While the ``empty_diff`` setting is included for backwards-compatibility, :program:`webchanges` uses the easier job
While the ``empty-diff`` setting is included for backwards-compatibility, :program:`webchanges` uses the easier job
directive :ref:`additions_only` to obtain similar results, which you should use. This deprecated setting controls
what happens if a page is ``changed``, but due to e.g. a ``diff_filter`` the diff is reduced to the empty string. If set
to ``true``, :program:`webchanges`: will report an (empty) change. If set to ``false``, the change will not be included
Expand Down
2 changes: 1 addition & 1 deletion tests/data/config.yaml
Expand Up @@ -2,7 +2,7 @@ display:
new: true
error: true
unchanged: false
empty_diff: true
empty-diff: true
report:
tz:
text:
Expand Down
7 changes: 4 additions & 3 deletions tests/test_jobs.py
@@ -1,5 +1,6 @@
"""Test running of jobs.
"""

from __future__ import annotations

import asyncio
Expand All @@ -23,7 +24,7 @@
from webchanges.handler import JobState
from webchanges.jobs import BrowserJob, BrowserResponseError, JobBase, NotModifiedError, ShellJob, UrlJob
from webchanges.main import Urlwatch
from webchanges.storage import CacheSQLite3Storage, Config, YamlConfigStorage, YamlJobsStorage
from webchanges.storage import _Config, CacheSQLite3Storage, YamlConfigStorage, YamlJobsStorage

here = Path(__file__).parent
data_path = here.joinpath('data')
Expand Down Expand Up @@ -472,7 +473,7 @@ def test_shell_job_without_kind() -> None:
def test_with_defaults() -> None:
job_data = {'url': 'https://www.example.com'}
job = JobBase.unserialize(job_data)
config: Config = {'job_defaults': {'all': {'timeout': 999}}} # type: ignore[typeddict-item]
config: _Config = {'job_defaults': {'all': {'timeout': 999}}} # type: ignore[typeddict-item]
job = job.with_defaults(config)
assert job.timeout == 999
assert job.get_indexed_location() == 'Job 0: https://www.example.com'
Expand All @@ -483,7 +484,7 @@ def test_with_defaults_headers() -> None:
override those more generic (i.e. ``all``)."""
job_data = {'url': 'https://www.example.com'}
job = JobBase.unserialize(job_data)
config: Config = { # type: ignore[typeddict-item]
config: _Config = { # type: ignore[typeddict-item]
'job_defaults': {
'all': {'headers': {'a': 1, 'b': 2}},
'url': {'headers': {'b': 3, 'c': 4}},
Expand Down
2 changes: 1 addition & 1 deletion webchanges/__init__.py
Expand Up @@ -21,7 +21,7 @@
# * MINOR version when you add functionality in a backwards compatible manner, and
# * MICRO or PATCH version when you make backwards compatible bug fixes. We no longer use '0'
# If unsure on increments, use pkg_resources.parse_version to parse
__version__ = '3.18'
__version__ = '3.18.1'
__description__ = (
'Check web (or command output) for changes since last run and notify.\n'
'\n'
Expand Down
14 changes: 7 additions & 7 deletions webchanges/command.py
Expand Up @@ -70,8 +70,8 @@
logger = logging.getLogger(__name__)

if TYPE_CHECKING:
from webchanges.reporters import ConfigReportersList
from webchanges.storage import ConfigReportEmail, ConfigReportEmailSmtp, ConfigReportTelegram, ConfigReportXmpp
from webchanges.reporters import _ConfigReportersList
from webchanges.storage import _ConfigReportEmail, _ConfigReportEmailSmtp, _ConfigReportTelegram, _ConfigReportXmpp


class UrlwatchCommand:
Expand Down Expand Up @@ -733,7 +733,7 @@ def edit_config(self) -> int:
return result

def check_telegram_chats(self) -> None:
config: ConfigReportTelegram = self.urlwatcher.config_storage.config['report']['telegram']
config: _ConfigReportTelegram = self.urlwatcher.config_storage.config['report']['telegram']

bot_token = config['bot_token']
if not bot_token:
Expand Down Expand Up @@ -822,7 +822,7 @@ def set_error(job_state: 'JobState', message: str) -> JobState:
print(f'\nSupported reporters:\n{ReporterBase.reporter_documentation()}\n')
return 1

cfg: ConfigReportersList = self.urlwatcher.config_storage.config['report'][
cfg: _ConfigReportersList = self.urlwatcher.config_storage.config['report'][
reporter_name # type: ignore[literal-required]
]
if job_state: # we want a full report
Expand Down Expand Up @@ -885,8 +885,8 @@ def set_error(job_state: 'JobState', message: str) -> JobState:
return 0

def check_smtp_login(self) -> None:
config: ConfigReportEmail = self.urlwatcher.config_storage.config['report']['email']
smtp_config: ConfigReportEmailSmtp = config['smtp']
config: _ConfigReportEmail = self.urlwatcher.config_storage.config['report']['email']
smtp_config: _ConfigReportEmailSmtp = config['smtp']

success = True

Expand Down Expand Up @@ -937,7 +937,7 @@ def check_smtp_login(self) -> None:
self._exit(0)

def check_xmpp_login(self) -> None:
xmpp_config: ConfigReportXmpp = self.urlwatcher.config_storage.config['report']['xmpp']
xmpp_config: _ConfigReportXmpp = self.urlwatcher.config_storage.config['report']['xmpp']

success = True

Expand Down
6 changes: 3 additions & 3 deletions webchanges/handler.py
Expand Up @@ -45,7 +45,7 @@
if TYPE_CHECKING:
from webchanges.jobs import JobBase
from webchanges.main import Urlwatch
from webchanges.storage import CacheStorage, Config
from webchanges.storage import _Config, CacheStorage

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -545,7 +545,7 @@ def __init__(self, urlwatch: Urlwatch) -> None:
:param urlwatch: The Urlwatch object with the program configuration information.
"""
self.config: Config = urlwatch.config_storage.config
self.config: _Config = urlwatch.config_storage.config

def _result(self, verb: str, job_state: JobState) -> None:
"""Logs error and appends the verb to the job_state.
Expand Down Expand Up @@ -623,7 +623,7 @@ def get_filtered_job_states(self, job_states: list[JobState]) -> Iterator[JobSta
):
if (
job_state.verb == 'changed'
and not self.config['display'].get('empty_diff', True)
and not self.config['display'].get('empty-diff', True)
and job_state.get_diff() == ''
):
continue
Expand Down
4 changes: 2 additions & 2 deletions webchanges/jobs.py
Expand Up @@ -39,7 +39,7 @@
# https://stackoverflow.com/questions/39740632
if TYPE_CHECKING:
from webchanges.handler import JobState
from webchanges.storage import Config
from webchanges.storage import _Config

try:
import httpx
Expand Down Expand Up @@ -396,7 +396,7 @@ def _set_defaults(self, defaults: Optional[dict[str, Any]]) -> None:
if hasattr(self, key) and subkey not in getattr(self, key):
getattr(self, key)[subkey] = subvalue

def with_defaults(self, config: Config) -> 'JobBase':
def with_defaults(self, config: _Config) -> 'JobBase':
"""Obtain a Job object that also contains defaults from the configuration.
:param config: The configuration as a dict.
Expand Down

0 comments on commit 516643e

Please sign in to comment.