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
4 changes: 2 additions & 2 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ self-hosted-runner:
labels: []
config-variables: null
paths:
. github/workflows/*.yml:
ignore:
. github/workflows/*.yml:
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path key appears to contain an unintended space (. github/workflows/*.yml:) which likely prevents actionlint from matching workflow files under .github/workflows/*.yml. Replace it with the correct path (no space) so the ignore rules apply.

Suggested change
. github/workflows/*.yml:
.github/workflows/*.yml:

Copilot uses AI. Check for mistakes.
ignore:
- 'SC2086' # Allow unquoted variables in shell (common in workflows)
- ".+SC1090.+"
2 changes: 1 addition & 1 deletion .github/workflows/maintain-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
DEBIAN_FRONTEND: noninteractive
LC_ALL: C
GITHUB_TOKEN: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

jobs:
maintain:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/update-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
PYTHON_COLORS: 0
LC_ALL: C
GITHUB_TOKEN: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
jobs:
jobs:
update-mirror:
name: Download & Mirror AdLists
runs-on: ubuntu-latest
Expand All @@ -46,7 +46,7 @@ jobs:
id: update
run: |
set -e; mkdir -p lists/mirror
uv run python3 -OO Scripts/update-lists.py --output-dir lists/mirror --max-concurrent 8
uv run python3 -OO -m Scripts.update_lists --output-dir lists/mirror --max-concurrent 8
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow now runs -m Scripts.update_lists, which requires an importable module named Scripts.update_lists (i.e., a file Scripts/update_lists.py). In this diff, the updater file being modified is Scripts/update-lists.py (hyphen), which cannot be imported as Scripts.update_lists. Rename the script to Scripts/update_lists.py (and update references) or revert the workflow to executing the script by path.

Suggested change
uv run python3 -OO -m Scripts.update_lists --output-dir lists/mirror --max-concurrent 8
uv run python3 -OO Scripts/update-lists.py --output-dir lists/mirror --max-concurrent 8

Copilot uses AI. Check for mistakes.
- name: Run dead domains linter
if: success()
continue-on-error: true
Expand All @@ -60,7 +60,7 @@ jobs:
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git remote set-branches origin adlists-mirror || :
git remote set-branches origin adlists-mirror || :
git fetch --depth=1 -nq origin adlists-mirror || git checkout -b adlists-mirror
- name: Commit changes
id: commit
Expand Down
2 changes: 1 addition & 1 deletion .serena/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ read_only: false

# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
# Below is the complete list of tools for convenience.
# To make sure you have the latest list of tools, and to view their descriptions,
# To make sure you have the latest list of tools, and to view their descriptions,
# execute `uv run scripts/print_tool_overview.py`.
#
# * `activate_project`: Activates a project by name.
Expand Down
4 changes: 2 additions & 2 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
extends: default

rules:
line-length:
line-length:
max: 120
level: warning
indentation:
spaces: 2
comments:
min-spaces-from-content: 1
document-start: disable
truthy:
truthy:
allowed-values: ["true", "false"]
braces:
max-spaces-inside: 0
Expand Down
8 changes: 4 additions & 4 deletions Scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ build_hostlist(){
}
[[ -f configuration_popup_filter.json ]] && {
hostlist-compiler -c configuration_popup_filter.json -o "$FILTER_OUT/adguard_popup_filter.txt" --verbose || warn "Popup filter compilation failed"
[[ -f scripts/popup_filter_build.js ]] && node scripts/popup_filter_build.js "$FILTER_OUT/adguard_popup_filter.txt" || :
[[ -f scripts/popup_filter_build.js ]] && node scripts/popup_filter_build.js "$FILTER_OUT/adguard_popup_filter.txt" || :
}
}

Expand Down Expand Up @@ -179,15 +179,15 @@ build_userscripts(){
mapfile -t files < <(find "$SCRIPT_SRC" -type f -name "*.js" 2>/dev/null)
(( ${#files[@]} == 0 )) && { log userscripts "No files in $SCRIPT_SRC"; return 0; }
log userscripts "Processing ${#files[@]} files"
has eslint && eslint --fix --quiet --no-warn-ignored "${files[@]}" 2>/dev/null || :
has eslint && eslint --fix --quiet --no-warn-ignored "${files[@]}" 2>/dev/null || :
export -f _process_js ok err warn
export REPO SCRIPT_OUT R G Y N RUNNER
RUNNER=$(runner)
if [[ -n $(par) ]] && (( ${#files[@]} > 1 )); then
printf '%s\n' "${files[@]}" | "$(par)" -j "$(jobs)" --bar _process_js {} 2>/dev/null || :
printf '%s\n' "${files[@]}" | "$(par)" -j "$(jobs)" --bar _process_js {} 2>/dev/null || :
else
for f in "${files[@]}"; do
_process_js "$f" || :
_process_js "$f" || :
done
fi
[[ -f $SCRIPT_LIST ]] && cp "$SCRIPT_LIST" "$SCRIPT_OUT/README.md"
Expand Down
3 changes: 1 addition & 2 deletions Scripts/deduplicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from dataclasses import dataclass
from collections.abc import Iterable


from common import is_valid_domain, write_lines
from Scripts.common import is_valid_domain, write_lines

HEADER_PREFIXES = ("! ", "#", "[", ";")

Expand Down
2 changes: 1 addition & 1 deletion Scripts/hosts-creator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ process(){
[[ ${RM_COMMENTS:-1} == 1 ]] && awk_cmd="!/^#/"
[[ ${RM_TRAILING_SPACES:-1} == 1 ]] && awk_cmd="${awk_cmd:+$awk_cmd && }{gsub(/^ +| +$/,\"\");print}"
[[ ${RM_DUPLICATE_LINES:-1} == 1 ]] && awk_cmd="${awk_cmd:+$awk_cmd && }! seen[\$0]++"

if [[ -n $awk_cmd ]]; then
local tmp
tmp=$(mktemp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from collections import defaultdict

# Import common utilities

from common import is_valid_domain, read_lines, write_lines
from Scripts.common import is_valid_domain, read_lines, write_lines


def is_pure_domain(line: str) -> bool:
Expand Down
28 changes: 24 additions & 4 deletions Scripts/test_common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import unittest
import sys
import io
import tempfile
from pathlib import Path
import hashlib
from unittest.mock import patch


from common import sanitize_filename, is_valid_domain, is_adguard_rule
from Scripts.common import sanitize_filename, is_valid_domain, is_adguard_rule, read_lines


class TestCommon(unittest.TestCase):
Expand Down Expand Up @@ -84,9 +86,27 @@ def test_is_adguard_rule(self):
self.assertTrue(is_adguard_rule("! comment"))
self.assertFalse(is_adguard_rule("example.com"))

def test_read_lines(self):
with tempfile.TemporaryDirectory() as temp_dir:
temp_dir_path = Path(temp_dir)
target_file = temp_dir_path / "test.txt"
target_file.write_text("line1 \nline2\r\nline3", encoding="utf-8")

lines = read_lines(target_file)
self.assertEqual(lines, ["line1", "line2", "line3"])

def test_read_lines_file_not_found(self):
with tempfile.TemporaryDirectory() as temp_dir:
temp_dir_path = Path(temp_dir)
non_existent = temp_dir_path / "missing.txt"

with patch("sys.stderr", new_callable=io.StringIO) as mock_stderr:
lines = read_lines(non_existent)
self.assertIsNone(lines)
self.assertIn(f"Error reading {non_existent}", mock_stderr.getvalue())

def test_write_lines_atomic(self):
import tempfile
from common import write_lines
from Scripts.common import write_lines

with tempfile.TemporaryDirectory() as temp_dir:
temp_dir_path = Path(temp_dir)
Expand Down
6 changes: 2 additions & 4 deletions Scripts/test_deduplicate.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import unittest
import sys
from pathlib import Path


from deduplicate import process_content, is_header, is_valid_rule
# Add current directory to path to allow importing deduplicate
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says the test adds the current directory to sys.path, but the code no longer does that and instead imports from Scripts.deduplicate. Update/remove the comment to reflect the current import approach to avoid confusion during maintenance.

Suggested change
# Add current directory to path to allow importing deduplicate
# Import deduplication helpers from the Scripts.deduplicate module

Copilot uses AI. Check for mistakes.
from Scripts.deduplicate import process_content, is_header, is_valid_rule


class TestDeduplicate(unittest.TestCase):
Expand Down
8 changes: 2 additions & 6 deletions Scripts/test_is_pure_domain_logic.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import unittest
import sys
from pathlib import Path
import importlib


# Import ADGUARD_INDICATORS from common
from common import ADGUARD_INDICATORS
from Scripts.common import ADGUARD_INDICATORS

# Import is_pure_domain from move-pure-domains
move_pure_domains = importlib.import_module("move-pure-domains")
is_pure_domain = move_pure_domains.is_pure_domain
from Scripts.move_pure_domains import is_pure_domain
Comment on lines +5 to +8
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These imports assume Scripts.move_pure_domains exists as an importable module (typically Scripts/move_pure_domains.py). In this PR, the script file is Scripts/move-pure-domains.py (hyphen), which cannot be imported as a Python module with that name. Either rename the script to move_pure_domains.py or switch back to a dynamic import by file path.

Copilot uses AI. Check for mistakes.


class TestIsPureDomain(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion Scripts/test_move_pure_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from unittest.mock import Mock, mock_open

# Import the module dynamically
file_path = Path(__file__).parent / "move-pure-domains.py"
file_path = Path(__file__).parent / "move_pure_domains.py"
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test now loads move_pure_domains.py, but the corresponding script shown in this PR is move-pure-domains.py (hyphen). As written, the dynamic import will fail with a missing file error. Align the test with the actual filename, or rename the script to move_pure_domains.py and update other references accordingly.

Suggested change
file_path = Path(__file__).parent / "move_pure_domains.py"
file_path = Path(__file__).parent / "move-pure-domains.py"

Copilot uses AI. Check for mistakes.
spec = importlib.util.spec_from_file_location("move_pure_domains", file_path)
if spec is None or spec.loader is None:
raise ImportError("Could not load module")
Expand Down
3 changes: 2 additions & 1 deletion Scripts/test_update_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class ClientError(Exception):
sys.modules["aiohttp"] = aiohttp_mock
sys.modules["aiofiles"] = MagicMock()

spec = importlib.util.spec_from_file_location("update_lists", "Scripts/update-lists.py")
spec = importlib.util.spec_from_file_location("update_lists", "Scripts/update_lists.py")
>>>>>>> origin/jules/fix-sys-path-boilerplate-6564146397324574189
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an unresolved merge-conflict marker (>>>>>>> ...) in the test file, which will cause a syntax error. Remove the conflict marker and ensure the chosen spec_from_file_location path matches the actual updater script filename in Scripts/.

Suggested change
>>>>>>> origin/jules/fix-sys-path-boilerplate-6564146397324574189

Copilot uses AI. Check for mistakes.
update_lists = importlib.util.module_from_spec(spec)
sys.modules["update_lists"] = update_lists
spec.loader.exec_module(update_lists)
Expand Down
3 changes: 1 addition & 2 deletions Scripts/update-lists.py → Scripts/update_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import aiofiles

# Import common utilities

from common import sanitize_filename
from Scripts.common import sanitize_filename

# ============================================================================
# CONFIGURATION
Expand Down
2 changes: 1 addition & 1 deletion Scripts/userscript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if has biome; then
biome check --fix --unsafe --skip-parse-errors --no-errors-on-unmatched --html-formatter-line-width=120 --css-formatter-line-width=120 --json-formatter-line-width=120 \
--use-editorconfig=true --indent-style=space --format-with-errors=true --files-ignore-unknown=true --vcs-use-ignore-file=false "$PWD"
fi
if has ruff; then
if has ruff; then
ruff format --line-length 120 --target-version py311 "$PWD"
fi
has yamlfmt && { yamlfmt -continue_on_error "*.yaml"; yamlfmt -continue_on_error "*.yml"; }
Expand Down
2 changes: 1 addition & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ PYTHONOPTIMIZE = "2"
PYTHONDONTWRITEBYTECODE = "1"
PYTHONNODEBUGRANGES = "1"
PYTHONUTF8 = "1"
PYTHONIOENCODING = "UTF-8"
PYTHONIOENCODING = "UTF-8"
UV_LINK_MODE = "hardlink"
DO_NOT_TRACK = "1"
CARGO_NET_GIT_FETCH_WITH_CLI = "false"
Expand Down
Loading