Skip to content

Commit 748e6af

Browse files
author
root
committed
your commit message
1 parent df2260a commit 748e6af

7 files changed

Lines changed: 49 additions & 59 deletions

File tree

.vscode/c_cpp_properties.json

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
{
2-
"configurations": [
3-
{
4-
"name": "Linux",
5-
"includePath": [
6-
"${fileDirname}/../**",
7-
"~/.pyenv/versions/3.8.19/include/python3.8"
8-
],
9-
"defines": [
10-
"_DEBUG",
11-
"UNICODE",
12-
"_UNICODE"
13-
],
14-
"windowsSdkVersion": "10.0.18362.0",
15-
"compilerPath": "/usr/bin/clang",
16-
"cStandard": "c11",
17-
"cppStandard": "c++17",
18-
"intelliSenseMode": "linux-clang-x64"
19-
}
20-
],
21-
"version": 4
22-
}
23-
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${fileDirname}/../**",
7+
"~/.pyenv/versions/3.8.19/include/python3.8"
8+
],
9+
"defines": [
10+
"_DEBUG",
11+
"UNICODE",
12+
"_UNICODE"
13+
],
14+
"windowsSdkVersion": "10.0.18362.0",
15+
"compilerPath": "/usr/bin/clang",
16+
"cStandard": "c11",
17+
"cppStandard": "c++17",
18+
"intelliSenseMode": "linux-clang-x64"
19+
}
20+
],
21+
"version": 4
22+
}

.vscode/settings.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"files.associations": {
3-
"*.py": "python",
4-
"*.ts": "typescript",
5-
"newtype_init.h": "c",
6-
"stddef.h": "c",
7-
"newtype_meth.h": "c",
8-
"python.h": "c",
9-
"structmember.h": "c",
10-
"newtype_debug_print.h": "c"
11-
}
12-
}
2+
"files.associations": {
3+
"*.py": "python",
4+
"*.ts": "typescript",
5+
"newtype_init.h": "c",
6+
"stddef.h": "c",
7+
"newtype_meth.h": "c",
8+
"python.h": "c",
9+
"structmember.h": "c",
10+
"newtype_debug_print.h": "c"
11+
}
12+
}

TODOS

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/examples/advanced_examples.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@ class TimedDict(NewType(dict)):
99
def __init__(self):
1010
super().__init__()
1111
self.operation_times = {}
12-
12+
1313
def __getitem__(self, key):
1414
start = time.time()
1515
result = super().__getitem__(key)
1616
elapsed = time.time() - start
1717
self.operation_times[key] = elapsed
1818
return result
19-
19+
2020
def get_stats(self):
2121
return self.operation_times
2222

23+
2324
# Usage
2425
d = TimedDict()
2526
d["key"] = "value"
@@ -37,7 +38,7 @@ class EmailStr(NewType(str)):
3738
if strict and '@' not in value:
3839
raise ValueError("Invalid email format")
3940
super().__init__()
40-
41+
4142
@property
4243
def domain(self) -> Optional[str]:
4344
if '@' in self:
@@ -58,11 +59,11 @@ class LoggedList(NewType(list)):
5859
def __init__(self, logger=None):
5960
super().__init__()
6061
self.logger = logger or logging.getLogger(__name__)
61-
62+
6263
def __enter__(self):
6364
self.logger.info("Starting list operations")
6465
return self
65-
66+
6667
def __exit__(self, exc_type, exc_val, exc_tb):
6768
self.logger.info("Finished list operations")
6869
if exc_type:

docs/examples/real_world.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ class ConfigDict(NewType(dict)):
1212
self.config_file = Path(config_file)
1313
if self.config_file.exists():
1414
self.load()
15-
15+
1616
def load(self):
1717
with open(self.config_file) as f:
1818
self.update(json.load(f))
19-
19+
2020
def save(self):
2121
with open(self.config_file, 'w') as f:
2222
json.dump(self, f, indent=2)
23-
23+
2424
def __setitem__(self, key, value):
2525
super().__setitem__(key, value)
2626
self.save() # Auto-save on changes
@@ -40,20 +40,20 @@ class ValidatedDict(NewType(dict)):
4040
def __init__(self, schema: Dict[str, Any]):
4141
super().__init__()
4242
self.schema = schema
43-
43+
4444
def __setitem__(self, key: str, value: Any):
4545
if key not in self.schema:
4646
raise KeyError(f"Key '{key}' not in schema")
47-
47+
4848
expected_type = self.schema[key].get('type')
4949
if not isinstance(value, expected_type):
5050
raise TypeError(f"Value for '{key}' must be {expected_type}")
51-
51+
5252
pattern = self.schema[key].get('pattern')
5353
if pattern and isinstance(value, str):
5454
if not re.match(pattern, value):
5555
raise ValueError(f"Value for '{key}' doesn't match pattern {pattern}")
56-
56+
5757
super().__setitem__(key, value)
5858

5959
# Usage
@@ -78,7 +78,7 @@ class AuditedDict(NewType(dict)):
7878
def __init__(self, audit_file: str = "audit.log"):
7979
super().__init__()
8080
self.audit_file = audit_file
81-
81+
8282
def _log_operation(self, operation: str, key: str, value: Any = None):
8383
log_entry = {
8484
'timestamp': datetime.now().isoformat(),
@@ -88,11 +88,11 @@ class AuditedDict(NewType(dict)):
8888
}
8989
with open(self.audit_file, 'a') as f:
9090
f.write(json.dumps(log_entry) + '\n')
91-
91+
9292
def __setitem__(self, key, value):
9393
self._log_operation('set', key, value)
9494
super().__setitem__(key, value)
95-
95+
9696
def __delitem__(self, key):
9797
self._log_operation('delete', key)
9898
super().__delitem__(key)

newtype/extensions/newtype_debug_print.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
#define DEBUG_PRINT(...)
1616
#endif
1717

18-
#endif // DEBUG_H
18+
#endif // DEBUG_H

requirements.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)