linter: Add lint rule banning 'import os.path'

This commit is contained in:
Juliana Bacelar 2017-09-22 13:30:18 -03:00 committed by Tim Abbott
parent f965a156a9
commit 928dd06cc8
10 changed files with 11 additions and 9 deletions

View File

@ -3,7 +3,7 @@ Use libraries from a virtualenv (by modifying sys.path) in production.
Also add Zulip's root directory to sys.path Also add Zulip's root directory to sys.path
""" """
import os.path import os
import sys import sys
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

View File

@ -326,6 +326,9 @@ def build_custom_checkers(by_lang):
{'pattern': 'from os.path', {'pattern': 'from os.path',
'description': "Don't use from when importing from the standard library", 'description': "Don't use from when importing from the standard library",
}, },
{'pattern': 'import os.path',
'description': "Use import os instead of import os.path",
},
]) + whitespace_rules ]) + whitespace_rules
bash_rules = [ bash_rules = [
{'pattern': '#!.*sh [-xe]', {'pattern': '#!.*sh [-xe]',

View File

@ -23,7 +23,7 @@
from __future__ import print_function from __future__ import print_function
import sys import sys
import os.path import os
import optparse import optparse
import time import time
import json import json

View File

@ -11,7 +11,7 @@ import logging
import traceback import traceback
from six.moves import urllib from six.moves import urllib
import re import re
import os.path import os
import glob import glob
import html import html
import twitter import twitter

View File

@ -18,7 +18,6 @@ import base64
import random import random
import sys import sys
import os import os
import os.path
import hashlib import hashlib
import six import six

View File

@ -1,5 +1,5 @@
from __future__ import absolute_import from __future__ import absolute_import
import os.path import os
from typing import Dict, List, Optional, TypeVar, Any, Text from typing import Dict, List, Optional, TypeVar, Any, Text
from django.conf import settings from django.conf import settings

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import from __future__ import absolute_import
import re import re
import os.path import os
import sourcemap import sourcemap
from six.moves import map from six.moves import map

View File

@ -1,5 +1,5 @@
from typing import Dict, Optional, Any, List from typing import Dict, Optional, Any, List
import os.path import os
from django.conf import settings from django.conf import settings
from django.template import Library, loader, engines from django.template import Library, loader, engines

View File

@ -1,7 +1,7 @@
from django.conf.urls import url from django.conf.urls import url
from django.conf import settings from django.conf import settings
from django.views.generic import TemplateView from django.views.generic import TemplateView
import os.path import os
from django.views.static import serve from django.views.static import serve
import zerver.views.registration import zerver.views.registration
import zerver.views.auth import zerver.views.auth

View File

@ -3,7 +3,7 @@ from django.conf.urls import url, include
from django.conf.urls.i18n import i18n_patterns from django.conf.urls.i18n import i18n_patterns
from django.views.generic import TemplateView, RedirectView from django.views.generic import TemplateView, RedirectView
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
import os.path import os
import zerver.forms import zerver.forms
from zproject import dev_urls from zproject import dev_urls
from zproject.legacy_urls import legacy_urls from zproject.legacy_urls import legacy_urls