Skip to content

Commit 37d3257

Browse files
Fix name clashes with python built-ins
This is preventing us from doing this in extract_text.py: from email.parser import Parser as EmailParser Because email already exists as a module
1 parent 10b1ac0 commit 37d3257

File tree

15 files changed

+21
-13
lines changed

15 files changed

+21
-13
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@ repos:
1818
rev: 5.0.4
1919
hooks:
2020
- id: flake8
21+
additional_dependencies:
22+
- flake8-builtins==2.5.0
2123
- repo: https://github.com/asottile/yesqa
2224
rev: v1.5.0
2325
hooks:
2426
- id: yesqa
27+
additional_dependencies:
28+
- flake8-builtins==2.5.0
2529
- repo: https://github.com/pre-commit/pygrep-hooks
2630
rev: v1.9.0
2731
hooks:

cardinal_pythonlib/django/fields/jsonclassfield.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def my_decoder_hook(d: Dict) -> Any:
130130
# noinspection PyUnresolvedReferences
131131
from django.db.models import TextField
132132

133-
from cardinal_pythonlib.json.serialize import json_decode, json_encode
133+
from cardinal_pythonlib.json_utils.serialize import json_decode, json_encode
134134

135135

136136
# =============================================================================

cardinal_pythonlib/django/function_cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from django.core.cache import cache # default cache
3737

3838
from cardinal_pythonlib.logs import get_brace_style_log_with_null_handler
39-
from cardinal_pythonlib.json.serialize import json_encode
39+
from cardinal_pythonlib.json_utils.serialize import json_encode
4040

4141
log = get_brace_style_log_with_null_handler(__name__)
4242

cardinal_pythonlib/django/middleware.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import logging
3030
import os
31-
from re import compile
31+
import re
3232
import sys
3333
from typing import Optional
3434

@@ -107,9 +107,9 @@ def process_exception(
107107
Modified according to: https://djangosnippets.org/snippets/2845/
108108
"""
109109

110-
# EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))]
110+
# EXEMPT_URLS = [re.compile(settings.LOGIN_URL.lstrip('/'))]
111111
# if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
112-
# EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
112+
# EXEMPT_URLS += [re.compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
113113
#
114114
#
115115
# class LoginRequiredMiddleware:
@@ -166,10 +166,10 @@ def process_exception(
166166
# 3. RNC; composite of those patterns.
167167
# -----------------------------------------------------------------------------
168168

169-
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip("/"))]
169+
EXEMPT_URLS = [re.compile(settings.LOGIN_URL.lstrip("/"))]
170170
if hasattr(settings, "LOGIN_EXEMPT_URLS"):
171171
EXEMPT_URLS += [
172-
compile(expr.lstrip("/")) for expr in settings.LOGIN_EXEMPT_URLS
172+
re.compile(expr.lstrip("/")) for expr in settings.LOGIN_EXEMPT_URLS
173173
]
174174

175175

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# cardinal_pythonlib/json/__init__.py
2+
# cardinal_pythonlib/json_utils/__init__.py
33

44
"""
55
===============================================================================

cardinal_pythonlib/json/serialize.py renamed to cardinal_pythonlib/json_utils/serialize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# cardinal_pythonlib/json/serialize.py
2+
# cardinal_pythonlib/json_utils/serialize.py
33

44
"""
55
===============================================================================

0 commit comments

Comments
 (0)