Skip to content
Merged
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
11 changes: 11 additions & 0 deletions .github/actions/build-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ runs:
with:
python-version: ${{ inputs.python-version }}

- name: Install lxml system deps (Linux only)
shell: bash
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y \
libxml2-dev \
libxslt1-dev \
python3-dev \
build-essential

- name: Install host python dependencies
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Build the project
uses: ./.github/actions/build-project
with:
python-version: '3.x'
python-version: '3.9'

gh-pages:
needs: build
Expand All @@ -35,7 +35,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: ./build
pattern: build.*.Linux-py3.x
pattern: build.*.Linux-py3.9
merge-multiple: true

- name: Deploy to Github Pages
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.x', '3.9']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
os: [ubuntu-latest, windows-latest]

name: Build ${{ matrix.os }}-py${{ matrix.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.9'

- name: Lint sources
shell: bash
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [4.0.2] - 2025-12-22

### Fixed
- API credentials checking from [Issue #42](https://github.com/b3yc0d3/rule34Py/issues/42)

## [4.0.1] - 2025-08-31

### Changed
Expand Down
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing

Thanks for taking an interest in contributing to the rule34Py project!

* This project's **canonical upstream** is at https://github.com/b3yc0d3/rule34Py.
* File **bugs**, **enhancement requests**, and other **issues** to the GH issue tracker at https://github.com/b3yc0d3/rule34Py/issues.
* See the [Developer Guide](https://b3yc0d3.github.io/rule34Py/dev/developer-guide.html) for information about how to **build** this project from source and run tests.


## Submitting Changes

#. Base your development branch off of the [upstream](https://github.com/b3yc0d3/rule34Py/tree/develop) ``develop`` reference.

#. Before committing your changes, run the **project linter** using ``make``. It will use the ``ruff`` to lint all the project sources.

.. code-block:: bash

poetry install # Optional, if you have not done it previously.
make lint

Fix or respond to any findings in the linter.

#. Run the project's test suite against your changes. Ensure that all tests pass.

.. code-block:: bash

poetry install # Optional, if you have not done it previously.
make check

#. Write a good commit message. If you are unsure of how, [this cbeams article](https://cbea.ms/git-commit/) gives reasonable suggestions. Commit your changes.

#. Fork the canonical upstream repository on github. \[[GitHub Docs](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo)\]

#. Push your development branch to your own fork. [Open a new Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) against the upstream `develop` ref.

#. Submit your PR. Respond to any PR build failures or feedback from the maintainers.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ maintainers = [
]
readme = "README.md"
requires-python = ">=3.9, <4.0"
version = "4.0.1"
version = "4.0.2"


[project.urls]
Expand Down
2 changes: 1 addition & 1 deletion rule34Py/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rule34Py - Python api wrapper for rule34.xxx
#
# Copyright (C) 2022-2024 b3yc0d3 <b3yc0d3@gmail.com>
# Copyright (C) 2022-2025 b3yc0d3 <b3yc0d3@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion rule34Py/rule34.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _get(self, *args, **kwargs) -> requests.Response:
is_api_request = args[0].startswith(__api_url__) == True

# check if api credentials are set
if is_api_request and self.user_id == None and self.api_key == None:
if is_api_request and self.user_id == None or self.api_key == None or (self.user_id == None and self.api_key == None):
raise ValueError(
"API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information."
)
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/test_rule34Py.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,25 @@ def test_rule34Py_top_tags(rule34):
assert isinstance(top_tags, list)
assert len(top_tags) == 100
assert isinstance(top_tags[0], TopTag)

def test_rule34Py_api_key(rule34):
rule34.api_key = None
with pytest.raises(ValueError) as execinfo:
rule34.top_tags()

assert str(execinfo.value) == "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information."

def test_rule34Py_user_id(rule34):
rule34.user_id = None
with pytest.raises(ValueError) as execinfo:
rule34.top_tags()

assert str(execinfo.value) == "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information."

def test_rule34Py_credentials(rule34):
rule34.api_key = None
rule34.user_id = None
with pytest.raises(ValueError) as execinfo:
rule34.top_tags()

assert str(execinfo.value) == "API credentials must be supplied, api_key and user_id can not be None!\nSee https://api.rule34.xxx/ for more information."