Skip to content

Commit 3b59b94

Browse files
committed
chore: remove mypy and pytest, fix linting
- Remove mypy from dependencies and configs - Remove pytest and coverage tools (no tests in project) - Fix ruff linting issues across codebase - Disable line length checks (E501) - Format all files with ruff
1 parent df249f2 commit 3b59b94

File tree

12 files changed

+416
-346
lines changed

12 files changed

+416
-346
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,4 @@ jobs:
2727
run: uv run ruff check
2828

2929
- name: Run ruff format check
30-
run: uv run ruff format --check
31-
32-
- name: Type check with mypy
33-
run: uv run mypy src/namecheap
30+
run: uv run ruff format --check

.pre-commit-config.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,3 @@ repos:
1818
args: [--fix]
1919
- id: ruff-format
2020

21-
- repo: https://github.com/pre-commit/mirrors-mypy
22-
rev: v1.11.0
23-
hooks:
24-
- id: mypy
25-
args: [--strict]
26-
additional_dependencies:
27-
- pydantic>=2.5.0
28-
- httpx>=0.27.0
29-
- types-xmltodict>=0.13.0
30-
- python-dotenv>=1.0.0
31-
- tldextract>=5.0.0
32-
files: ^src/

examples/quickstart.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@
4747
try:
4848
# Get current DNS records for a domain
4949
# Use the first domain from your account, or specify one
50-
domain_name = my_domains[0].name if my_domains else "example.com" # Replace with your domain
50+
domain_name = (
51+
my_domains[0].name if my_domains else "example.com"
52+
) # Replace with your domain
5153
print(f"Current DNS records for {domain_name}:")
5254

5355
records = nc.dns.get(domain_name)

pyproject.toml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@ all = [
5050
"textual>=0.47.0",
5151
]
5252
dev = [
53-
"pytest>=8.0.0",
54-
"pytest-asyncio>=0.23.0",
55-
"pytest-cov>=5.0.0",
56-
"pytest-httpx>=0.30.0",
5753
"ruff>=0.7.0",
58-
"mypy>=1.11.0",
59-
"types-xmltodict>=0.13.0",
6054
]
6155

6256
[project.scripts]
@@ -72,7 +66,6 @@ packages = ["src/namecheap", "src/namecheap_cli", "src/namecheap_dns_tui"]
7266

7367
[tool.ruff]
7468
target-version = "py312"
75-
line-length = 100
7669
src = ["src"]
7770

7871
[tool.ruff.lint]
@@ -88,36 +81,13 @@ select = [
8881
"RET", # flake8-return
8982
"SIM", # flake8-simplify
9083
]
84+
# Ignore line length
85+
extend-ignore = ["E501"]
9186
ignore = [
9287
"S101", # Use of assert detected - reasonable for tests and validation
9388
"SIM110", # Use any() - no current violations, keeping for edge cases
9489
"SIM118", # Use `key in dict` instead of `key in dict.keys()` - no current violations
9590
]
9691

97-
[tool.mypy]
98-
python_version = "3.12"
99-
strict = true
100-
pretty = true
101-
show_error_codes = true
102-
show_error_context = true
10392

104-
[tool.pytest.ini_options]
105-
minversion = "8.0"
106-
testpaths = ["tests"]
107-
addopts = "-ra --cov=namecheap --cov-report=term-missing"
10893

109-
[tool.coverage.run]
110-
source = ["src/namecheap"]
111-
112-
[tool.coverage.report]
113-
exclude_lines = [
114-
"pragma: no cover",
115-
"def __repr__",
116-
"if TYPE_CHECKING:",
117-
"raise NotImplementedError",
118-
]
119-
120-
[dependency-groups]
121-
dev = [
122-
"types-pyyaml>=6.0.12.20250516",
123-
]

src/namecheap/_api/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ def normalize_xml_response(data: dict[str, Any]) -> dict[str, Any]:
5656
# Fix known typos from Namecheap
5757
if key == "@YourAdditonalCost": # Their typo (missing 'i' in Additional)
5858
normalized["@YourAdditionalCost"] = value # Correct spelling
59-
logger.debug("Fixed Namecheap typo: @YourAdditonalCost -> @YourAdditionalCost")
59+
logger.debug(
60+
"Fixed Namecheap typo: @YourAdditonalCost -> @YourAdditionalCost"
61+
)
6062

6163
# Debug canary: Alert if they have both versions (means they're fixing it)
6264
if "@YourAdditionalCost" in data and "@YourAdditonalCost" in data:
@@ -70,7 +72,8 @@ def normalize_xml_response(data: dict[str, Any]) -> dict[str, Any]:
7072
normalized[key] = normalize_xml_response(value)
7173
elif isinstance(value, list):
7274
normalized[key] = [
73-
normalize_xml_response(item) if isinstance(item, dict) else item for item in value
75+
normalize_xml_response(item) if isinstance(item, dict) else item
76+
for item in value
7477
]
7578

7679
return normalized

src/namecheap/_api/dns.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ def a(self, name: str, ip: str, ttl: int = 1800) -> Self:
3535
Self for chaining
3636
"""
3737
self._records.append(
38-
DNSRecord.model_validate({"@Name": name, "@Type": "A", "@Address": ip, "@TTL": ttl})
38+
DNSRecord.model_validate(
39+
{"@Name": name, "@Type": "A", "@Address": ip, "@TTL": ttl}
40+
)
3941
)
4042
return self
4143

@@ -94,7 +96,13 @@ def mx(self, name: str, server: str, priority: int = 10, ttl: int = 1800) -> Sel
9496
"""
9597
self._records.append(
9698
DNSRecord.model_validate(
97-
{"@Name": name, "@Type": "MX", "@Address": server, "@TTL": ttl, "@MXPref": priority}
99+
{
100+
"@Name": name,
101+
"@Type": "MX",
102+
"@Address": server,
103+
"@TTL": ttl,
104+
"@MXPref": priority,
105+
}
98106
)
99107
)
100108
return self

src/namecheap/_api/domains.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
class DomainsAPI(BaseAPI):
1818
"""Domain management operations."""
1919

20-
def check(self, *domains: str, include_pricing: bool = False) -> builtins.list[DomainCheck]:
20+
def check(
21+
self, *domains: str, include_pricing: bool = False
22+
) -> builtins.list[DomainCheck]:
2123
"""
2224
Check domain availability.
2325
@@ -158,7 +160,9 @@ def register(
158160

159161
# Add contact info if provided
160162
if contact:
161-
contact_data = contact.model_dump() if isinstance(contact, Contact) else contact
163+
contact_data = (
164+
contact.model_dump() if isinstance(contact, Contact) else contact
165+
)
162166
# Add contact fields for all types (Registrant, Tech, Admin, AuxBilling)
163167
for contact_type in ["Registrant", "Tech", "Admin", "AuxBilling"]:
164168
for field, value in contact_data.items():
@@ -284,7 +288,9 @@ def unlock(self, domain: str) -> bool:
284288
assert isinstance(result, dict)
285289
return bool(result)
286290

287-
def _get_pricing(self, domains: builtins.list[str]) -> dict[str, dict[str, Decimal | None]]:
291+
def _get_pricing(
292+
self, domains: builtins.list[str]
293+
) -> dict[str, dict[str, Decimal | None]]:
288294
"""
289295
Get pricing information for domains.
290296
@@ -362,23 +368,29 @@ def _get_pricing(self, domains: builtins.list[str]) -> dict[str, dict[str, Decim
362368
if not isinstance(products, list):
363369
products = [products] if products else []
364370

365-
logger.debug(f"Found {len(products)} products in REGISTER category")
371+
logger.debug(
372+
f"Found {len(products)} products in REGISTER category"
373+
)
366374

367375
# Find the product matching our TLD
368376
for product in products:
369377
if not isinstance(product, dict):
370378
continue
371379

372380
product_name = product.get("@Name", "")
373-
logger.debug(f"Checking product: {product_name} vs {tld}")
381+
logger.debug(
382+
f"Checking product: {product_name} vs {tld}"
383+
)
374384

375385
if product_name.lower() == tld.lower():
376386
# Get price list
377387
price_info = product.get("Price", [])
378388
if not isinstance(price_info, list):
379389
price_info = [price_info] if price_info else []
380390

381-
logger.debug(f"Found {len(price_info)} price entries for {tld}")
391+
logger.debug(
392+
f"Found {len(price_info)} price entries for {tld}"
393+
)
382394

383395
# Find 1 year price
384396
for price in price_info:
@@ -405,13 +417,17 @@ def _get_pricing(self, domains: builtins.list[str]) -> dict[str, dict[str, Decim
405417
# Apply to all domains with this TLD
406418
for domain in domain_list:
407419
pricing[domain] = {
408-
"regular_price": Decimal(regular_price)
420+
"regular_price": Decimal(
421+
regular_price
422+
)
409423
if regular_price
410424
else None,
411425
"your_price": Decimal(your_price)
412426
if your_price
413427
else None,
414-
"retail_price": Decimal(retail_price)
428+
"retail_price": Decimal(
429+
retail_price
430+
)
415431
if retail_price
416432
else None,
417433
}

src/namecheap/logging.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,21 @@ def show(error: Exception, *, show_traceback: bool = False) -> None:
7474

7575
if hasattr(error, "_ip_help") and error._ip_help is not None:
7676
console.print("\n[yellow]🔍 IP Configuration Issue[/yellow]")
77-
console.print(f" Your current IP: [cyan]{error._ip_help['actual_ip']}[/cyan]")
78-
console.print(f" Configured IP: [cyan]{error._ip_help['configured_ip']}[/cyan]")
77+
console.print(
78+
f" Your current IP: [cyan]{error._ip_help['actual_ip']}[/cyan]"
79+
)
80+
console.print(
81+
f" Configured IP: [cyan]{error._ip_help['configured_ip']}[/cyan]"
82+
)
7983
console.print("\n[yellow]💡 To fix this:[/yellow]")
80-
console.print(" 1. Log in to [link=https://www.namecheap.com]Namecheap[/link]")
84+
console.print(
85+
" 1. Log in to [link=https://www.namecheap.com]Namecheap[/link]"
86+
)
8187
console.print(" 2. Go to Profile → Tools → API Access")
8288
actual_ip = error._ip_help["actual_ip"]
83-
console.print(f" 3. Add this IP to whitelist: [cyan]{actual_ip}[/cyan]")
89+
console.print(
90+
f" 3. Add this IP to whitelist: [cyan]{actual_ip}[/cyan]"
91+
)
8492
console.print(
8593
f" 4. Update your .env file: [cyan]NAMECHEAP_CLIENT_IP={actual_ip}[/cyan]"
8694
)

src/namecheap/models.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ class DomainCheck(XMLModel):
8989
"""
9090

9191
domain: str = Field(alias="@Domain", description="Domain name checked")
92-
available: bool = Field(alias="@Available", description="Whether domain is available")
92+
available: bool = Field(
93+
alias="@Available", description="Whether domain is available"
94+
)
9395
premium: bool = Field(
9496
default=False,
9597
alias="@IsPremiumName",
@@ -182,8 +184,8 @@ class DNSRecord(XMLModel):
182184
"""A DNS record."""
183185

184186
name: str = Field(alias="@Name", default="@")
185-
type: Literal["A", "AAAA", "CNAME", "MX", "NS", "TXT", "URL", "URL301", "FRAME"] = Field(
186-
alias="@Type"
187+
type: Literal["A", "AAAA", "CNAME", "MX", "NS", "TXT", "URL", "URL301", "FRAME"] = (
188+
Field(alias="@Type")
187189
)
188190
value: str = Field(alias="@Address")
189191
ttl: int = Field(alias="@TTL", default=1800)

0 commit comments

Comments
 (0)