Skip to content

Commit

Permalink
fixed dataclasses headers default
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnaglodha committed Jan 14, 2025
1 parent 8e1b687 commit 231be04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/geoserverx/_async/gsx.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Optional, Union
from dataclasses import dataclass, field
from typing import Dict, Optional, Union

import httpx

Expand Down Expand Up @@ -51,11 +51,14 @@ class AsyncGeoServerX:
password (str): GeoServer password.
"""

default_headers = {"Content-Type": "application/json"}
username: str = "admin"
password: str = "geoserver"
url: str = "http://127.0.0.1:8080/geoserver/rest/"
headers: dict = default_headers
headers: Dict[str, str] = field(
default_factory=lambda: {
"Content-Type": "application/json",
}
)

def __post_init__(self):
if not self.username and not self.password and not self.url:
Expand Down
11 changes: 7 additions & 4 deletions src/geoserverx/_sync/gsx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional, Union
from typing import Dict, Optional, Union

import httpx
from pydantic import ValidationError
Expand Down Expand Up @@ -62,11 +62,14 @@ class SyncGeoServerX:
password (str): GeoServer password.
"""

default_headers = {"Content-Type": "application/json"}
username: str = "admin"
password: str = "geoserver"
url: str = "http://127.0.0.1:8080/geoserver/rest/"
headers: dict = default_headers
headers: Dict[str, str] = field(
default_factory=lambda: {
"Content-Type": "application/json",
}
)

def __post_init__(self):
if not self.username and not self.password and not self.url:
Expand Down

0 comments on commit 231be04

Please sign in to comment.