Skip to content

Drop Python 3.8 support #41

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

Merged
merged 3 commits into from
Jun 13, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/precommits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout Repository
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ venv.bak/
.mypy_cache/

tests/e2e/screenshots
.DS_Store
.DS_Store

# claude
.claude
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## 1.2.0
- Drop Python 3.8 support

## 1.1.3
- Updated dependencies to fix security vulnerabilities

Expand Down
6 changes: 3 additions & 3 deletions playwright_stealth/core/_stealth_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from dataclasses import dataclass
from typing import Dict, Tuple, Optional
from typing import Optional
import os
from playwright_stealth.properties import Properties, BrowserType

Expand All @@ -12,7 +12,7 @@ def from_file(name) -> str:
return f.read()


SCRIPTS: Dict[str, str] = {
SCRIPTS: dict[str, str] = {
"chrome_csi": from_file("chrome.csi.js"),
"chrome_app": from_file("chrome.app.js"),
"chrome_runtime": from_file("chrome.runtime.js"),
Expand Down Expand Up @@ -76,7 +76,7 @@ def enabled_scripts():
nav_vendor: str = "Google Inc."
nav_user_agent: str = None
nav_platform: str = None
languages: Tuple[str, str] = ("en-US", "en")
languages: tuple[str, str] = ("en-US", "en")
run_on_insecure_origins: Optional[bool] = None

def enabled_scripts(self, properties: Properties):
Expand Down
5 changes: 2 additions & 3 deletions playwright_stealth/properties/_header_properties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dataclasses import dataclass
from typing import List


@dataclass
Expand All @@ -23,7 +22,7 @@ class HeaderProperties:

def __init__(
self,
brands: List[dict],
brands: list[dict],
dnt: str,
client_hint_headers_enabled: bool = True,
**kwargs,
Expand Down Expand Up @@ -61,7 +60,7 @@ def _generate_sec_ch_ua_platform(self) -> str:
else:
return "Unknown"

def _generate_sec_ch_ua(self, brands: List[dict]) -> str:
def _generate_sec_ch_ua(self, brands: list[dict]) -> str:
"""Generates the Sec_Ch_Ua based brands generated"""
merged_brands = "".join([f'"{brand["brand"]}";v="{brand["version"]}",' for brand in brands])
return merged_brands
Expand Down
9 changes: 4 additions & 5 deletions playwright_stealth/properties/_navigator_properties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dataclasses import dataclass
from typing import List


@dataclass
Expand All @@ -9,17 +8,17 @@ class NavigatorProperties:
userAgent: str
platform: str
language: str
languages: List[str]
languages: list[str]
appVersion: str
vendor: str
deviceMemory: int
hardwareConcurrency: int
maxTouchPoints: int
doNotTrack: str
brands: List[dict]
brands: list[dict]
mobile: bool

def __init__(self, brands: List[dict], dnt: str, **kwargs):
def __init__(self, brands: list[dict], dnt: str, **kwargs):
self.userAgent = kwargs["User-Agent"]

# Shared properties
Expand Down Expand Up @@ -55,7 +54,7 @@ def _generate_language(self) -> str:

return "en-US"

def _generate_languages(self, accept_language: str) -> List[str]:
def _generate_languages(self, accept_language: str) -> list[str]:
"""Generates the languages based on the accept language."""

languages_with_quality = accept_language.split(",")
Expand Down
7 changes: 3 additions & 4 deletions playwright_stealth/properties/_viewport_properties.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from dataclasses import dataclass
from typing import Tuple
import random


Expand All @@ -19,13 +18,13 @@ def __init__(self, **kwargs):
self.outerWidth, self.outerHeight = self._generate_outer_dimensions()
self.innerWidth, self.innerHeight = self._generate_inner_dimensions()

def _generate_viewport_dimensions(self) -> Tuple[int, int]:
def _generate_viewport_dimensions(self) -> tuple[int, int]:
return 1920 + random.randint(-100, 100), 1080 + random.randint(-100, 100)

def _generate_outer_dimensions(self) -> Tuple[int, int]:
def _generate_outer_dimensions(self) -> tuple[int, int]:
return self.width, self.height

def _generate_inner_dimensions(self) -> Tuple[int, int]:
def _generate_inner_dimensions(self) -> tuple[int, int]:
return (
self.width - random.randint(0, 20),
self.height - random.randint(0, 20),
Expand Down
702 changes: 131 additions & 571 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "tf-playwright-stealth"
packages = [{ include = "playwright_stealth" }]
version = "1.1.3"
version = "1.2.0"
description = "Makes playwright stealthy like a ninja!"
authors = []
homepage = "https://www.agentql.com/"
Expand All @@ -10,7 +10,7 @@ license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
playwright = "^1"
fake-http-header = "^0.3.5"

Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/configs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from typing import List
from pydantic import BaseModel

from tests.utils import from_file
Expand Down Expand Up @@ -28,7 +27,7 @@ def __hash__(self):

class MultipleScriptConfig(BaseModel):
name: str
script: List[str]
script: list[str]
query: str
url: str

Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/test_multiple_scripts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest
import agentql
import logging
from typing import List
from playwright.sync_api import sync_playwright, Page as SyncPage
from playwright.async_api import async_playwright, Page as AsyncPage
from .configs import (
Expand All @@ -27,7 +26,7 @@
log = logging.getLogger(__name__)


def extract_query_lines(query_str) -> List[str]:
def extract_query_lines(query_str) -> list[str]:
"""This function is used to extract the query lines from the query string"""
lines = query_str.strip().splitlines()
return [
Expand Down