Skip to content

fix: importlib-metadata as a dependency on Python>=3.10 #839

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

Closed
wants to merge 4 commits into from
Closed
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
6 changes: 5 additions & 1 deletion zulip_bots/zulip_bots/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
import importlib.abc
import importlib.util
import os
import sys
from pathlib import Path
from types import ModuleType
from typing import Any, Optional, Tuple

current_dir = os.path.dirname(os.path.abspath(__file__))

import importlib_metadata as metadata
if sys.version_info >= (3, 10):
from importlib.metadata import metadata # Python 3.10+ standard library
else:
from importlib_metadata import metadata # External package for Python < 3.10


def import_module_from_source(path: str, name: str) -> Any:
Expand Down
5 changes: 3 additions & 2 deletions zulip_bots/zulip_bots/tests/test_finder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from pathlib import Path
from unittest import TestCase

from unittest.mock import patch
from zulip_bots import finder


Expand All @@ -11,4 +12,4 @@ def test_resolve_bot_path(self) -> None:
expected_bot_name = "helloworld"
expected_bot_path_and_name = (expected_bot_path, expected_bot_name)
actual_bot_path_and_name = finder.resolve_bot_path("helloworld")
self.assertEqual(expected_bot_path_and_name, actual_bot_path_and_name)
self.assertEqual(expected_bot_path_and_name, actual_bot_path_and_name)
Loading