diff --git a/.gitea/workflows/analysis.yml b/.gitea/workflows/analysis.yml new file mode 100644 index 0000000..50053fc --- /dev/null +++ b/.gitea/workflows/analysis.yml @@ -0,0 +1,24 @@ +name: Analysis + +on: + push: + branches: + - main + - dev + pull_request: + types: [opened, synchronize, reopened] + +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + container: catthehacker/ubuntu:act-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index 2bdabf4..a1ba4c6 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -10,11 +10,12 @@ on: jobs: test: + name: Build and Test runs-on: ubuntu-latest container: catthehacker/ubuntu:act-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 @@ -35,4 +36,4 @@ jobs: - uses: actions/upload-artifact@v3 with: name: Artifacts - path: dist/* + path: dist/* \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index c9f761f..2029037 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,17 +8,17 @@ dynamic = ["version", "dependencies", "optional-dependencies"] authors = [{ name = "Profitroll" }] description = "Universal bot library with functions needed for basic Discord/Telegram bot development." readme = "README.md" -requires-python = ">=3.8" +requires-python = ">=3.9" license = { text = "GPLv3" } classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Operating System :: OS Independent", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", ] @@ -42,7 +42,7 @@ Tracker = "https://git.end-play.xyz/profitroll/LibBotUniversal/issues" where = ["src"] [tool.black] -target-version = ['py38', 'py39', 'py310', 'py311'] +target-version = ['py39', 'py310', 'py311' ,'py312'] [tool.isort] profile = "black" @@ -61,7 +61,7 @@ show_error_codes = true [tool.pylint.main] extension-pkg-whitelist = ["ujson"] -py-version = 3.8 +py-version = 3.9 [tool.coverage.run] source = ["libbot"] diff --git a/requirements/dev.txt b/requirements/dev.txt index 566d360..761c547 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -1,11 +1,11 @@ -black==24.4.2 -build==1.2.1 +black==24.10.0 +build==1.2.2.post1 isort==5.13.2 -mypy==1.10.1 -pylint==3.2.5 -pytest-asyncio==0.23.7 -pytest-cov==5.0.0 -pytest==8.2.2 -tox==4.16.0 +mypy==1.13.0 +pylint==3.3.2 +pytest-asyncio==0.25.0 +pytest-cov==6.0.0 +pytest==8.3.4 +tox==4.23.2 types-aiofiles==24.1.0.20240626 types-ujson==5.10.0.20240515 \ No newline at end of file diff --git a/requirements/pycord.txt b/requirements/pycord.txt index 520f02f..1742a0a 100644 --- a/requirements/pycord.txt +++ b/requirements/pycord.txt @@ -1,2 +1,2 @@ -apscheduler~=3.10.4 +apscheduler~=3.11.0 py-cord~=2.6.0 \ No newline at end of file diff --git a/requirements/pyrogram.txt b/requirements/pyrogram.txt index 572ac17..8599c5f 100644 --- a/requirements/pyrogram.txt +++ b/requirements/pyrogram.txt @@ -1,2 +1,2 @@ -apscheduler~=3.10.4 +apscheduler~=3.11.0 pyrofork~=2.3.32 \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..25798e9 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +sonar.projectKey=profitroll_libbot +sonar.organization=profitroll \ No newline at end of file diff --git a/src/libbot/__init__.py b/src/libbot/__init__.py index a2c0bdf..2a3d63c 100644 --- a/src/libbot/__init__.py +++ b/src/libbot/__init__.py @@ -1,4 +1,4 @@ -__version__ = "3.2.3" +__version__ = "3.3.0" __license__ = "GPL3" __author__ = "Profitroll" diff --git a/src/libbot/__main__.py b/src/libbot/__main__.py index eb696e1..ffb36f3 100644 --- a/src/libbot/__main__.py +++ b/src/libbot/__main__.py @@ -11,6 +11,8 @@ except ImportError: from ._utils import supports_argument from .sync._nested import nested_delete, nested_set +DEFAULT_CONFIG_LOCATION: str = "config.json" + async def json_read(path: Union[str, Path]) -> Any: """Read contents of a JSON file @@ -43,7 +45,7 @@ async def json_write(data: Any, path: Union[str, Path]) -> None: async def config_get( - key: str, *path: str, config_file: Union[str, Path] = "config.json" + key: str, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION ) -> Any: """Get a value of the config key by its path provided For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"` @@ -83,7 +85,7 @@ async def config_get( async def config_set( - key: str, value: Any, *path: str, config_file: Union[str, Path] = "config.json" + key: str, value: Any, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION ) -> None: """Set config's key by its path to the value @@ -99,14 +101,13 @@ async def config_set( await json_write( nested_set(await json_read(config_file), value, *(*path, key)), config_file ) - return async def config_delete( key: str, *path: str, missing_ok: bool = False, - config_file: Union[str, Path] = "config.json", + config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION, ) -> None: """Set config's key by its path diff --git a/src/libbot/pyrogram/classes/client.py b/src/libbot/pyrogram/classes/client.py index c246434..450aa13 100644 --- a/src/libbot/pyrogram/classes/client.py +++ b/src/libbot/pyrogram/classes/client.py @@ -358,7 +358,8 @@ class PyroClient(Client): ] logger.info( - "Registering commands %s with a default scope 'BotCommandScopeDefault'" + "Registering commands %s with a default scope 'BotCommandScopeDefault'", + commands ) await self.set_bot_commands(commands) diff --git a/src/libbot/sync/__main__.py b/src/libbot/sync/__main__.py index 7ece6cb..8ab01dc 100644 --- a/src/libbot/sync/__main__.py +++ b/src/libbot/sync/__main__.py @@ -9,6 +9,8 @@ try: except ImportError: from json import dumps, loads +DEFAULT_CONFIG_LOCATION: str = "config.json" + def json_read(path: Union[str, Path]) -> Any: """Read contents of a JSON file @@ -41,7 +43,7 @@ def json_write(data: Any, path: Union[str, Path]) -> None: def config_get( - key: str, *path: str, config_file: Union[str, Path] = "config.json" + key: str, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION ) -> Any: """Get a value of the config key by its path provided For example, `foo.bar.key` has a path of `"foo", "bar"` and the key `"key"` @@ -81,7 +83,7 @@ def config_get( def config_set( - key: str, value: Any, *path: str, config_file: Union[str, Path] = "config.json" + key: str, value: Any, *path: str, config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION ) -> None: """Set config's key by its path to the value @@ -95,14 +97,13 @@ def config_set( * `KeyError`: Key is not found under path provided """ json_write(nested_set(json_read(config_file), value, *(*path, key)), config_file) - return def config_delete( key: str, *path: str, missing_ok: bool = False, - config_file: Union[str, Path] = "config.json", + config_file: Union[str, Path] = DEFAULT_CONFIG_LOCATION, ) -> None: """Set config's key by its path diff --git a/tests/test_config_sync.py b/tests/test_config_sync.py index 522dcda..a13a494 100644 --- a/tests/test_config_sync.py +++ b/tests/test_config_sync.py @@ -59,7 +59,7 @@ def test_config_delete(key: str, path: List[str], location_config: Path): ("bot_lol", ["bot"]), ], ) -async def test_config_delete_missing(key: str, path: List[str], location_config: Path): +def test_config_delete_missing(key: str, path: List[str], location_config: Path): assert ( sync.config_delete(key, *path, missing_ok=True, config_file=location_config) is None diff --git a/tests/test_utils.py b/tests/test_utils.py index c0aef75..2dc3217 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -6,10 +6,12 @@ from libbot._utils import supports_argument def func1(foo: str, bar: str): + """Dummy function with specific arguments""" pass def func2(foo: str): + """Dummy function with specific arguments""" pass diff --git a/tox.ini b/tox.ini index 7aafed7..2d1f1c1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,14 +1,14 @@ [tox] -minversion = 3.8.0 -envlist = py38, py39, py310, py311 +minversion = 3.9.0 +envlist = py39, py310, py311, py312 isolated_build = true [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] setenv =