Skip to content

Conversation

@fcakyon
Copy link
Contributor

@fcakyon fcakyon commented Nov 9, 2025

Simplify package API by exporting AutoModerator directly from the main package.

- Add AutoModerator to package __init__.py with __all__ export
- Update all imports from 'moderators.auto_model' to 'moderators'
- Update example model references to viddexa/nsfw-detector-mini
@fcakyon fcakyon self-assigned this Nov 9, 2025
@fcakyon fcakyon added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 9, 2025
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

❌ Ruff Formatting Issues

The following formatting issues were found:

Would reformat: src/moderators/__init__.py
1 file would be reformatted, 16 files already formatted

🔧 How to fix:

Auto-format your code:

uv run ruff format .

This will automatically format all Python files to match the project style.

- Lower target version to py39 for broader compatibility
- Extend linter rules with F, RUF, and FA checks
- Add RUF-specific ignores for Unicode ambiguity and mutable defaults
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

❌ Ruff Linting Issues

The following linting issues were found:

RUF022 [*] `__all__` is not sorted
  --> src/moderators/utils/__init__.py:5:11
   |
 3 |   from .image import preprocess_image_input
 4 |
 5 |   __all__ = [
   |  ___________^
 6 | |     "auto_install",
 7 | |     "ensure_transformers",
 8 | |     "ensure_dl_framework",
 9 | |     "ensure_pillow_for_task",
10 | |     "preprocess_image_input",
11 | | ]
   | |_^
   |
help: Apply an isort-style sorting to `__all__`

RUF100 [*] Unused `noqa` directive (unused: `F401`)
  --> src/moderators/utils/deps.py:32:47
   |
30 |     """Ensure 'transformers' is importable; optionally auto-install and retry."""
31 |     try:
32 |         import transformers as _transformers  # noqa: F401
   |                                               ^^^^^^^^^^^^
33 |
34 |         return _transformers
   |
help: Remove unused `noqa` directive

RUF100 [*] Unused `noqa` directive (unused: `F401`)
  --> src/moderators/utils/deps.py:51:23
   |
49 |     """
50 |     try:
51 |         import torch  # noqa: F401
   |                       ^^^^^^^^^^^^
52 |
53 |         return "pt"
   |
help: Remove unused `noqa` directive

RUF100 [*] Unused `noqa` directive (unused: `F401`)
  --> src/moderators/utils/deps.py:84:21
   |
82 |         return
83 |     try:
84 |         import PIL  # noqa: F401
   |                     ^^^^^^^^^^^^
85 |     except Exception:
86 |         if not install_fn(["Pillow"]):
   |
help: Remove unused `noqa` directive

RUF046 Value being cast to `int` is already an integer
  --> src/moderators/utils/image.py:47:29
   |
45 |                 if w < min_side or h < min_side:
46 |                     scale = max(min_side / w, min_side / h)
47 |                     new_w = int(round(w * scale))
   |                             ^^^^^^^^^^^^^^^^^^^^^
48 |                     new_h = int(round(h * scale))
49 |                     resample = getattr(getattr(Image, "Resampling", Image), "BILINEAR")
   |
help: Remove unnecessary `int` call

RUF046 Value being cast to `int` is already an integer
  --> src/moderators/utils/image.py:48:29
   |
46 |                     scale = max(min_side / w, min_side / h)
47 |                     new_w = int(round(w * scale))
48 |                     new_h = int(round(h * scale))
   |                             ^^^^^^^^^^^^^^^^^^^^^
49 |                     resample = getattr(getattr(Image, "Resampling", Image), "BILINEAR")
50 |                     img = img.resize((new_w, new_h), resample)
   |
help: Remove unnecessary `int` call

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:17:50
   |
16 |     def __exit__(self, exc_type, exc, tb):
17 |         # Klasörü bilerek silmiyoruz; test sonrasında pytest tmp cleanup zaten yapar.
   |                                                  ^
18 |         return False
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:15
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |               ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:21
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                     ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:24
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                        ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:26
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                          ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:31
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                               ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:40
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                                        ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:42
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                                          ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:28:45
   |
27 | def test_push_to_hub_offline(tmp_path, monkeypatch, fake_transformers):
28 |     # Ağ ve ağır bağımlılıkları devre dışı bırak
   |                                             ^
29 |     monkeypatch.setenv("MODERATORS_DISABLE_AUTO_INSTALL", "1")
30 |     monkeypatch.setattr(
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:77:23
   |
75 |     mod = AutoModerator.from_pretrained(str(model_dir))
76 |
77 |     # push_to_hub çağrısı (ağ yok, FakeApi çalışacak)
   |                       ^
78 |     repo_id = "user/repo-for-tests"
79 |     mod.push_to_hub(repo_id, commit_message="test commit", token="fake-token")
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:77:25
   |
75 |     mod = AutoModerator.from_pretrained(str(model_dir))
76 |
77 |     # push_to_hub çağrısı (ağ yok, FakeApi çalışacak)
   |                         ^
78 |     repo_id = "user/repo-for-tests"
79 |     mod.push_to_hub(repo_id, commit_message="test commit", token="fake-token")
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:77:47
   |
75 |     mod = AutoModerator.from_pretrained(str(model_dir))
76 |
77 |     # push_to_hub çağrısı (ağ yok, FakeApi çalışacak)
   |                                               ^
78 |     repo_id = "user/repo-for-tests"
79 |     mod.push_to_hub(repo_id, commit_message="test commit", token="fake-token")
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:81:25
   |
79 |     mod.push_to_hub(repo_id, commit_message="test commit", token="fake-token")
80 |
81 |     # upload_folder çağrıldı mı?
   |                         ^
82 |     assert "upload_folder" in calls
83 |     up = calls["upload_folder"]
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:81:28
   |
79 |     mod.push_to_hub(repo_id, commit_message="test commit", token="fake-token")
80 |
81 |     # upload_folder çağrıldı mı?
   |                            ^
82 |     assert "upload_folder" in calls
83 |     up = calls["upload_folder"]
   |

RUF003 Comment contains ambiguous `ı` (LATIN SMALL LETTER DOTLESS I). Did you mean `i` (LATIN SMALL LETTER I)?
  --> tests/test_push_to_hub.py:81:31
   |
79 |     mod.push_to_hub(repo_id, commit_message="test commit", token="fake-token")
80 |
81 |     # upload_folder çağrıldı mı?
   |                               ^
82 |     assert "upload_folder" in calls
83 |     up = calls["upload_folder"]
   |

Found 21 errors.
[*] 4 fixable with the `--fix` option (2 hidden fixes can be enabled with the `--unsafe-fixes` option).

🔧 How to fix:

Option 1: Auto-fix (recommended)

uv run ruff check . --fix

Option 2: Check only

uv run ruff check .

💡 Most issues marked with [*] can be auto-fixed with the --fix flag.

@github-actions
Copy link

github-actions bot commented Nov 9, 2025

❌ Ruff Formatting Issues

The following formatting issues were found:

Would reformat: src/moderators/__init__.py
1 file would be reformatted, 16 files already formatted

🔧 How to fix:

Auto-format your code:

uv run ruff format .

This will automatically format all Python files to match the project style.

- Add missing newline at end of file in __init__.py
- Sort __all__ exports alphabetically in utils
- Remove unnecessary noqa comments from valid imports
- Remove redundant int() calls around round()
- Convert Turkish comments to English in tests
@fcakyon fcakyon merged commit 710b02e into main Nov 9, 2025
4 checks passed
@fcakyon fcakyon deleted the feature/export-auto-moderator branch November 9, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants