Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-jupyter-events for openSUSE:Factory checked in at 2024-04-02 16:40:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jupyter-events (Old) and /work/SRC/openSUSE:Factory/.python-jupyter-events.new.1905 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jupyter-events" Tue Apr 2 16:40:35 2024 rev:9 rq:1163573 version:0.10.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-jupyter-events/python-jupyter-events.changes 2024-02-06 16:40:29.379941981 +0100 +++ /work/SRC/openSUSE:Factory/.python-jupyter-events.new.1905/python-jupyter-events.changes 2024-04-02 16:40:57.666021956 +0200 @@ -1,0 +2,7 @@ +Fri Mar 29 18:22:29 UTC 2024 - Ben Greiner <c...@bnavigator.de> + +- Update to 0.10.0 + * Enable adding listeners to event before the event is registered + #97 (@Zsailer) + +------------------------------------------------------------------- Old: ---- jupyter_events-0.9.0.tar.gz New: ---- jupyter_events-0.10.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jupyter-events.spec ++++++ --- /var/tmp/diff_new_pack.KwkkSl/_old 2024-04-02 16:40:58.458051144 +0200 +++ /var/tmp/diff_new_pack.KwkkSl/_new 2024-04-02 16:40:58.462051291 +0200 @@ -24,7 +24,7 @@ %{?sle15_python_module_pythons} Name: python-jupyter-events -Version: 0.9.0 +Version: 0.10.0 Release: 0 Summary: Jupyter Event System library License: BSD-3-Clause ++++++ jupyter_events-0.9.0.tar.gz -> jupyter_events-0.10.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/.github/dependabot.yml new/jupyter_events-0.10.0/.github/dependabot.yml --- old/jupyter_events-0.9.0/.github/dependabot.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/.github/dependabot.yml 2020-02-02 01:00:00.000000000 +0100 @@ -4,7 +4,15 @@ directory: "/" schedule: interval: "weekly" + groups: + actions: + patterns: + - "*" - package-ecosystem: "pip" directory: "/" schedule: interval: "weekly" + groups: + actions: + patterns: + - "*" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/.github/workflows/prep-release.yml new/jupyter_events-0.10.0/.github/workflows/prep-release.yml --- old/jupyter_events-0.9.0/.github/workflows/prep-release.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/.github/workflows/prep-release.yml 2020-02-02 01:00:00.000000000 +0100 @@ -12,6 +12,10 @@ post_version_spec: description: "Post Version Specifier" required: false + silent: + description: "Set a placeholder in the changelog and don't publish the release." + required: false + type: boolean since: description: "Use PRs with activity since this date or git reference" required: false @@ -22,6 +26,8 @@ jobs: prep_release: runs-on: ubuntu-latest + permissions: + contents: write steps: - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 @@ -29,8 +35,9 @@ id: prep-release uses: jupyter-server/jupyter_releaser/.github/actions/prep-release@v2 with: - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} version_spec: ${{ github.event.inputs.version_spec }} + silent: ${{ github.event.inputs.silent }} post_version_spec: ${{ github.event.inputs.post_version_spec }} target: ${{ github.event.inputs.target }} branch: ${{ github.event.inputs.branch }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/.github/workflows/publish-changelog.yml new/jupyter_events-0.10.0/.github/workflows/publish-changelog.yml --- old/jupyter_events-0.9.0/.github/workflows/publish-changelog.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/.github/workflows/publish-changelog.yml 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,34 @@ +name: "Publish Changelog" +on: + release: + types: [published] + + workflow_dispatch: + inputs: + branch: + description: "The branch to target" + required: false + +jobs: + publish_changelog: + runs-on: ubuntu-latest + environment: release + steps: + - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + + - name: Publish changelog + id: publish-changelog + uses: jupyter-server/jupyter_releaser/.github/actions/publish-changelog@v2 + with: + token: ${{ steps.app-token.outputs.token }} + branch: ${{ github.event.inputs.branch }} + + - name: "** Next Step **" + run: | + echo "Merge the changelog update PR: ${{ steps.publish-changelog.outputs.pr_url }}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/.github/workflows/publish-release.yml new/jupyter_events-0.10.0/.github/workflows/publish-release.yml --- old/jupyter_events-0.9.0/.github/workflows/publish-release.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/.github/workflows/publish-release.yml 2020-02-02 01:00:00.000000000 +0100 @@ -15,30 +15,32 @@ jobs: publish_release: runs-on: ubuntu-latest + environment: release + permissions: + id-token: write steps: - uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ vars.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + - name: Populate Release id: populate-release uses: jupyter-server/jupyter_releaser/.github/actions/populate-release@v2 with: - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - target: ${{ github.event.inputs.target }} + token: ${{ steps.app-token.outputs.token }} branch: ${{ github.event.inputs.branch }} release_url: ${{ github.event.inputs.release_url }} steps_to_skip: ${{ github.event.inputs.steps_to_skip }} - name: Finalize Release id: finalize-release - env: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} - PYPI_TOKEN_MAP: ${{ secrets.PYPI_TOKEN_MAP }} - TWINE_USERNAME: __token__ - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - uses: jupyter-server/jupyter-releaser/.github/actions/finalize-release@v2 + uses: jupyter-server/jupyter_releaser/.github/actions/finalize-release@v2 with: - token: ${{ secrets.ADMIN_GITHUB_TOKEN }} - target: ${{ github.event.inputs.target }} + token: ${{ steps.app-token.outputs.token }} release_url: ${{ steps.populate-release.outputs.release_url }} - name: "** Next Step **" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/.pre-commit-config.yaml new/jupyter_events-0.10.0/.pre-commit-config.yaml --- old/jupyter_events-0.9.0/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 @@ -21,7 +21,7 @@ - id: trailing-whitespace - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.27.0 + rev: 0.27.4 hooks: - id: check-github-workflows @@ -33,7 +33,7 @@ [mdformat-gfm, mdformat-frontmatter, mdformat-footnote] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v4.0.0-alpha.8" hooks: - id: prettier types_or: [yaml, html, json] @@ -52,7 +52,7 @@ args: ["-L", "sur,nd"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: "v1.6.1" + rev: "v1.8.0" hooks: - id: mypy files: "^jupyter_events" @@ -77,14 +77,17 @@ - id: rst-inline-touching-normal - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.3 + rev: v0.2.0 hooks: - id: ruff + types_or: [python, jupyter] args: ["--fix", "--show-fixes"] - id: ruff-format + types_or: [python, jupyter] - repo: https://github.com/scientific-python/cookie - rev: "2023.10.27" + rev: "2024.01.24" hooks: - id: sp-repo-review additional_dependencies: ["repo-review[cli]"] + args: ["--ignore", "GH102"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/CHANGELOG.md new/jupyter_events-0.10.0/CHANGELOG.md --- old/jupyter_events-0.9.0/CHANGELOG.md 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/CHANGELOG.md 2020-02-02 01:00:00.000000000 +0100 @@ -4,6 +4,40 @@ <!-- <START NEW CHANGELOG ENTRY> --> +## 0.10.0 + +([Full Changelog](https://github.com/jupyter/jupyter_events/compare/v0.9.1...e7784fd09356ef074d69d1c2f192f1ad96f5f00c)) + +### Enhancements made + +- Enable adding listeners to event before the event is registered [#97](https://github.com/jupyter/jupyter_events/pull/97) ([@Zsailer](https://github.com/Zsailer)) + +### Contributors to this release + +([GitHub contributors page for this release](https://github.com/jupyter/jupyter_events/graphs/contributors?from=2024-03-12&to=2024-03-18&type=c)) + +[@Zsailer](https://github.com/search?q=repo%3Ajupyter%2Fjupyter_events+involves%3AZsailer+updated%3A2024-03-12..2024-03-18&type=Issues) + +<!-- <END NEW CHANGELOG ENTRY> --> + +## 0.9.1 + +([Full Changelog](https://github.com/jupyter/jupyter_events/compare/v0.9.0...014a91c793b12d008bb744614a280bc14b5be7eb)) + +### Maintenance and upkeep improvements + +- Update Release Scripts [#96](https://github.com/jupyter/jupyter_events/pull/96) ([@blink1073](https://github.com/blink1073)) +- chore: update pre-commit hooks [#95](https://github.com/jupyter/jupyter_events/pull/95) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- chore: update pre-commit hooks [#94](https://github.com/jupyter/jupyter_events/pull/94) ([@pre-commit-ci](https://github.com/pre-commit-ci)) +- Update ruff and typing [#93](https://github.com/jupyter/jupyter_events/pull/93) ([@blink1073](https://github.com/blink1073)) +- chore: update pre-commit hooks [#92](https://github.com/jupyter/jupyter_events/pull/92) ([@pre-commit-ci](https://github.com/pre-commit-ci)) + +### Contributors to this release + +([GitHub contributors page for this release](https://github.com/jupyter/jupyter_events/graphs/contributors?from=2023-11-06&to=2024-03-12&type=c)) + +[@blink1073](https://github.com/search?q=repo%3Ajupyter%2Fjupyter_events+involves%3Ablink1073+updated%3A2023-11-06..2024-03-12&type=Issues) | [@pre-commit-ci](https://github.com/search?q=repo%3Ajupyter%2Fjupyter_events+involves%3Apre-commit-ci+updated%3A2023-11-06..2024-03-12&type=Issues) + ## 0.9.0 ([Full Changelog](https://github.com/jupyter/jupyter_events/compare/v0.8.0...228a04801224d127f4304e17398464d045794cf0)) @@ -24,8 +58,6 @@ [@blink1073](https://github.com/search?q=repo%3Ajupyter%2Fjupyter_events+involves%3Ablink1073+updated%3A2023-10-16..2023-11-06&type=Issues) | [@frenzymadness](https://github.com/search?q=repo%3Ajupyter%2Fjupyter_events+involves%3Afrenzymadness+updated%3A2023-10-16..2023-11-06&type=Issues) -<!-- <END NEW CHANGELOG ENTRY> --> - ## 0.8.0 ([Full Changelog](https://github.com/jupyter/jupyter_events/compare/v0.7.0...e3edb6a868924d3f1b15eaf18d45be621ad77cef)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/PKG-INFO new/jupyter_events-0.10.0/PKG-INFO --- old/jupyter_events-0.9.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ -Metadata-Version: 2.1 +Metadata-Version: 2.3 Name: jupyter-events -Version: 0.9.0 +Version: 0.10.0 Summary: Jupyter Event System library Project-URL: Homepage, http://jupyter.org Project-URL: documentation, https://jupyter-events.readthedocs.io/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/docs/conf.py new/jupyter_events-0.10.0/docs/conf.py --- old/jupyter_events-0.9.0/docs/conf.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/docs/conf.py 2020-02-02 01:00:00.000000000 +0100 @@ -16,11 +16,10 @@ # -- Project information ----------------------------------------------------- - -from typing import List +from __future__ import annotations project = "jupyter_events" -copyright = "2019, Project Jupyter" # noqa +copyright = "2019, Project Jupyter" author = "Project Jupyter" @@ -29,10 +28,10 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions: List = ["myst_parser", "jupyterlite_sphinx"] +extensions: list = ["myst_parser", "jupyterlite_sphinx"] try: - import enchant # type:ignore # noqa + import enchant # noqa: F401 extensions += ["sphinxcontrib.spelling"] except ImportError: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/docs/demo/demo-notebook.ipynb new/jupyter_events-0.10.0/docs/demo/demo-notebook.ipynb --- old/jupyter_events-0.9.0/docs/demo/demo-notebook.ipynb 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/docs/demo/demo-notebook.ipynb 2020-02-02 01:00:00.000000000 +0100 @@ -13,6 +13,8 @@ "metadata": {}, "outputs": [], "source": [ + "from __future__ import annotations\n", + "\n", "import piplite\n", "\n", "await piplite.install(\"jupyter_events\")" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/jupyter_events/_version.py new/jupyter_events-0.10.0/jupyter_events/_version.py --- old/jupyter_events-0.9.0/jupyter_events/_version.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/jupyter_events/_version.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,17 +1,18 @@ """ store the current version info of jupyter-events. """ +from __future__ import annotations + import re -from typing import List # Version string must appear intact for hatch versioning -__version__ = "0.9.0" +__version__ = "0.10.0" # Build up version_info tuple for backwards compatibility pattern = r"(?P<major>\d+).(?P<minor>\d+).(?P<patch>\d+)(?P<rest>.*)" match = re.match(pattern, __version__) -assert match is not None # noqa -parts: List[object] = [int(match[part]) for part in ["major", "minor", "patch"]] +assert match is not None +parts: list[object] = [int(match[part]) for part in ["major", "minor", "patch"]] if match["rest"]: parts.append(match["rest"]) version_info = tuple(parts) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/jupyter_events/cli.py new/jupyter_events-0.10.0/jupyter_events/cli.py --- old/jupyter_events-0.9.0/jupyter_events/cli.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/jupyter_events/cli.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,4 +1,6 @@ """The cli for jupyter events.""" +from __future__ import annotations + import json import pathlib import platform @@ -46,7 +48,6 @@ https://raw.githubusercontent.com/jupyter/jupyter_events/main/jupyter_events/schemas/event-metaschema.yml """ - pass @click.command() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/jupyter_events/logger.py new/jupyter_events-0.10.0/jupyter_events/logger.py --- old/jupyter_events-0.9.0/jupyter_events/logger.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/jupyter_events/logger.py 2020-02-02 01:00:00.000000000 +0100 @@ -91,9 +91,7 @@ async def gather_listeners(self) -> list[t.Any]: """Gather all of the active listeners.""" - return await asyncio.gather( # type:ignore[no-any-return] - *self._active_listeners, return_exceptions=True - ) + return await asyncio.gather(*self._active_listeners, return_exceptions=True) @default("schemas") def _default_schemas(self) -> SchemaRegistry: @@ -120,8 +118,8 @@ def _load_config( self, cfg: Config, - section_names: list[str] | None = None, - traits: list[str] | None = None, # type:ignore[override] + section_names: list[str] | None = None, # noqa: ARG002 + traits: list[str] | None = None, # type:ignore[override] # noqa: ARG002 ) -> None: """Load EventLogger traits from a Config object, patching the handlers trait in the Config object to avoid deepcopy errors. @@ -144,12 +142,16 @@ Get this registered schema using the EventLogger.schema.get() method. """ - event_schema = self.schemas.register(schema) # type:ignore[arg-type] key = event_schema.id - self._modifiers[key] = set() - self._modified_listeners[key] = set() - self._unmodified_listeners[key] = set() + # It's possible that listeners and modifiers have been added for this + # schema before the schema is registered. + if key not in self._modifiers: + self._modifiers[key] = set() + if key not in self._modified_listeners: + self._modified_listeners[key] = set() + if key not in self._unmodified_listeners: + self._unmodified_listeners[key] = set() def register_handler(self, handler: logging.Handler) -> None: """Register a new logging handler to the Event Logger. @@ -207,7 +209,11 @@ # If the schema ID and version is given, only add # this modifier to that schema if schema_id: - self._modifiers[schema_id].add(modifier) + # If the schema hasn't been added yet, + # start a placeholder set. + modifiers = self._modifiers.get(schema_id, set()) + modifiers.add(modifier) + self._modifiers[schema_id] = modifiers return for id_ in self._modifiers: if schema_id is None or id_ == schema_id: @@ -266,9 +272,16 @@ # this modifier to that schema if schema_id: if modified: - self._modified_listeners[schema_id].add(listener) + # If the schema hasn't been added yet, + # start a placeholder set. + listeners = self._modified_listeners.get(schema_id, set()) + listeners.add(listener) + self._modified_listeners[schema_id] = listeners return - self._unmodified_listeners[schema_id].add(listener) + listeners = self._unmodified_listeners.get(schema_id, set()) + listeners.add(listener) + self._unmodified_listeners[schema_id] = listeners + return for id_ in self.schemas.schema_ids: if schema_id is None or id_ == schema_id: if modified: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/jupyter_events/schema.py new/jupyter_events-0.10.0/jupyter_events/schema.py --- old/jupyter_events-0.9.0/jupyter_events/schema.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/jupyter_events/schema.py 2020-02-02 01:00:00.000000000 +0100 @@ -3,7 +3,7 @@ import json from pathlib import Path, PurePath -from typing import Any, Union +from typing import Any, Dict, Union from jsonschema import FormatChecker, validators from referencing import Registry @@ -18,25 +18,19 @@ from .validators import draft7_format_checker, validate_schema -class EventSchemaUnrecognized(Exception): # noqa +class EventSchemaUnrecognized(Exception): """An error for an unrecognized event schema.""" - pass - class EventSchemaLoadingError(Exception): """An error for an event schema loading error.""" - pass - -class EventSchemaFileAbsent(Exception): # noqa +class EventSchemaFileAbsent(Exception): """An error for an absent event schema file.""" - pass - -SchemaType = Union[dict, str, PurePath] +SchemaType = Union[Dict[str, Any], str, PurePath] class EventSchema: @@ -141,7 +135,7 @@ raise EventSchemaUnrecognized(msg) @property - def id(self) -> str: # noqa + def id(self) -> str: """Schema $id field.""" return self._schema["$id"] # type:ignore[no-any-return] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/jupyter_events/schema_registry.py new/jupyter_events-0.10.0/jupyter_events/schema_registry.py --- old/jupyter_events-0.9.0/jupyter_events/schema_registry.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/jupyter_events/schema_registry.py 2020-02-02 01:00:00.000000000 +0100 @@ -6,7 +6,7 @@ from .schema import EventSchema -class SchemaRegistryException(Exception): # noqa: N818 +class SchemaRegistryException(Exception): """Exception class for Jupyter Events Schema Registry Errors.""" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/jupyter_events/traits.py new/jupyter_events-0.10.0/jupyter_events/traits.py --- old/jupyter_events-0.9.0/jupyter_events/traits.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/jupyter_events/traits.py 2020-02-02 01:00:00.000000000 +0100 @@ -44,8 +44,8 @@ return out # If a list, check it's elements to verify # that each element is a logging handler instance. - elif isinstance(value, list): + if isinstance(value, list): self.validate_elements(obj, value) return value - else: - self.error(obj, value) + self.error(obj, value) + return None # type:ignore[unreachable] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/pyproject.toml new/jupyter_events-0.10.0/pyproject.toml --- old/jupyter_events-0.9.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/pyproject.toml 2020-02-02 01:00:00.000000000 +0100 @@ -96,7 +96,10 @@ detached = true dependencies = ["pre-commit"] [tool.hatch.envs.lint.scripts] -build = "pre-commit run --all-files ruff" +build = [ + "pre-commit run --all-files ruff", + "pre-commit run --all-files ruff-format" +] [tool.hatch.envs.typing] dependencies = [ "pre-commit"] @@ -149,29 +152,41 @@ files = "jupyter_events" python_version = "3.8" strict = true -show_error_codes = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] warn_unreachable = true [tool.ruff] -target-version = "py38" line-length = 100 [tool.ruff.lint] -select = [ - "A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "N", - "PLC", "PLE", "PLR", "PLW", "Q", "RUF", "S", "SIM", "T", "TID", "UP", - "W", "YTT", +extend-select = [ + "B", # flake8-bugbear + "I", # isort + "ARG", # flake8-unused-arguments + "C4", # flake8-comprehensions + "EM", # flake8-errmsg + "ICN", # flake8-import-conventions + "G", # flake8-logging-format + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PL", # pylint + "PTH", # flake8-use-pathlib + "PT", # flake8-pytest-style + "RET", # flake8-return + "RUF", # Ruff-specific + "SIM", # flake8-simplify + "T20", # flake8-print + "UP", # pyupgrade + "YTT", # flake8-2020 + "EXE", # flake8-executable + "PYI", # flake8-pyi + "S", # flake8-bandit ] ignore = [ - # Q000 Single quotes found but double quotes preferred - "Q000", - # FBT001 Boolean positional arg in function definition - "FBT001", "FBT002", "FBT003", - # E501 Line too long (158 > 100 characters) - "E501", - # SIM105 Use `contextlib.suppress(...)` - "SIM105", + "E501", # E501 Line too long (158 > 100 characters) + "SIM105", # SIM105 Use `contextlib.suppress(...)` + "PLR", # Design related pylint codes + "S101", # Use of `assert` detected ] unfixable = [ # Don't touch print statements @@ -179,6 +194,7 @@ # Don't touch noqa lines "RUF100", ] +isort.required-imports = ["from __future__ import annotations"] [tool.ruff.lint.per-file-ignores] # B011 Do not call assert False since python -O removes these calls @@ -190,10 +206,15 @@ # N802 Function name `assertIn` should be lowercase # F841 Local variable `t` is assigned to but never used # S101 Use of `assert` detected -"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "F841", "S101"] +"tests/*" = ["B011", "F841", "C408", "E402", "T201", "B007", "N802", "F841", "S101", "ARG", "PGH"] # C901 Function is too complex "jupyter_events/logger.py" = ["C901"] # `emit` is too complex (12 > 10) +"docs/demo/demo-notebook.ipynb" = ["PLE1142", "E402", "T201"] +[tool.ruff.lint.flake8-pytest-style] +fixture-parentheses = false +mark-parentheses = false +parametrize-names-type = "csv" [tool.interrogate] ignore-init-module=true @@ -204,6 +225,3 @@ ignore-nested-classes=true fail-under=100 exclude = ["docs", "tests"] - -[tool.repo-review] -ignore = ["PY007", "GH102"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/conftest.py new/jupyter_events-0.10.0/tests/conftest.py --- old/jupyter_events-0.9.0/tests/conftest.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/conftest.py 2020-02-02 01:00:00.000000000 +0100 @@ -1 +1,3 @@ +from __future__ import annotations + pytest_plugins = ["jupyter_events.pytest_plugin"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/test_cli.py new/jupyter_events-0.10.0/tests/test_cli.py --- old/jupyter_events-0.9.0/tests/test_cli.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/test_cli.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import pytest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/test_listeners.py new/jupyter_events-0.10.0/tests/test_listeners.py --- old/jupyter_events-0.9.0/tests/test_listeners.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/test_listeners.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,9 +1,11 @@ +from __future__ import annotations + import io import logging import pytest -from jupyter_events.logger import EventLogger +from jupyter_events.logger import EventLogger, SchemaNotRegistered from jupyter_events.schema import EventSchema from .utils import SCHEMA_PATH @@ -42,7 +44,7 @@ event_logger = jp_event_logger listener_was_called = False - async def my_listener(logger: "EventLogger", schema_id: "str", data: "dict") -> "None": + async def my_listener(logger: EventLogger, schema_id: str, data: dict) -> None: nonlocal listener_was_called listener_was_called = True @@ -136,3 +138,41 @@ assert listener_was_called # Check that the active listeners are cleaned up. assert len(event_logger._active_listeners) == 0 + + +@pytest.mark.parametrize( + # Make sure no schemas are added at the start of this test. + "jp_event_schemas", + [ + # Empty events list. + [] + ], +) +async def test_listener_added_before_schemas_passes(jp_event_logger, schema): + # Ensure there are no schemas listed. + assert len(jp_event_logger.schemas.schema_ids) == 0 + + listener_was_called = False + + async def my_listener(logger: EventLogger, schema_id: str, data: dict) -> None: + nonlocal listener_was_called + listener_was_called = True + + # Add the listener without any schemas + jp_event_logger.add_listener(schema_id=schema.id, listener=my_listener) + + # Proof that emitting the event won't success + with pytest.warns(SchemaNotRegistered): + jp_event_logger.emit(schema_id=schema.id, data={"prop": "hello, world"}) + + assert not listener_was_called + + # Now register the event and emit. + jp_event_logger.register_event_schema(schema) + + # Try emitting the event again and ensure the listener saw it. + jp_event_logger.emit(schema_id=schema.id, data={"prop": "hello, world"}) + await jp_event_logger.gather_listeners() + assert listener_was_called + # Check that the active listeners are cleaned up. + assert len(jp_event_logger._active_listeners) == 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/test_logger.py new/jupyter_events-0.10.0/tests/test_logger.py --- old/jupyter_events-0.9.0/tests/test_logger.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/test_logger.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import json import logging @@ -40,8 +42,7 @@ # Load written file. loader = PyFileConfigLoader(filename, path=str(path)) - cfg = loader.load_config() - return cfg + return loader.load_config() def test_good_config_file(tmp_path): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/test_modifiers.py new/jupyter_events-0.10.0/tests/test_modifiers.py --- old/jupyter_events-0.9.0/tests/test_modifiers.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/test_modifiers.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from jupyter_events.schema import EventSchema diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/test_schema.py new/jupyter_events-0.10.0/tests/test_schema.py --- old/jupyter_events-0.9.0/tests/test_schema.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/test_schema.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from pathlib import Path @@ -31,7 +33,7 @@ a redactionPolicies field. """ # Read the schema file - with open(SCHEMA_PATH / "bad" / schema_file) as f: + with Path.open(SCHEMA_PATH / "bad" / schema_file) as f: schema = yaml.loads(f) # Assert that the schema files for a known reason. with pytest.raises(ValidationError) as err: @@ -49,7 +51,7 @@ """Ensure EventSchema returns a helpful error message if user passes a string intended as a Path.""" expected_msg_contents = "Paths to schema files must be explicitly wrapped in a Pathlib object." - str_path = os.path.join(SCHEMA_PATH, "good", "some_schema.yaml") + str_path = os.path.join(SCHEMA_PATH, "good", "some_schema.yaml") # noqa: PTH118 with pytest.raises(EventSchemaLoadingError) as e: EventSchema(str_path) @@ -79,7 +81,7 @@ def test_good_validations(schema_file): """Ensure validation passes for good schemas.""" # Read the schema file - with open(SCHEMA_PATH / "good" / schema_file) as f: + with Path.open(SCHEMA_PATH / "good" / schema_file) as f: schema = yaml.loads(f) # assert that no exception gets raised validate_schema(schema) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/test_traits.py new/jupyter_events-0.10.0/tests/test_traits.py --- old/jupyter_events-0.9.0/tests/test_traits.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/test_traits.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import logging import pytest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/jupyter_events-0.9.0/tests/utils.py new/jupyter_events-0.10.0/tests/utils.py --- old/jupyter_events-0.9.0/tests/utils.py 2020-02-02 01:00:00.000000000 +0100 +++ new/jupyter_events-0.10.0/tests/utils.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,5 @@ +from __future__ import annotations + import io import json import logging