Opened 13 years ago
Closed 13 years ago
#16225 closed Cleanup/optimization (fixed)
Unused imports all over the source
Reported by: | Jeffrey Gelens | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Uncategorized | Version: | 1.3 |
Severity: | Normal | Keywords: | dceu2011 |
Cc: | jeffrey@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
During the sprints I noticed a lot unused import are being done (checked via Pyflakes). I've talked with Russel about this and we decided to create a ticket. Well here it is.
Attachments (3)
Change History (14)
comment:1 by , 13 years ago
Cc: | added |
---|
comment:2 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 13 years ago
comment:4 by , 13 years ago
Owner: | changed from | to
---|
comment:5 by , 13 years ago
- When an import is no longer used, I used my judgement to determine if it could be removed without hurting backwards compatibility, for instance:
- It's generally unsafe to remove imports from
__init__.py
files (I touched only a few of these). - It's safe to remove
from django.conf import settings
when settings aren't used, except in the request handlers where we want the side effects of importing the settings for the first time. - It's safe to remove unused imports in
trunk/tests
, because third-party code shouldn't rely on them, except TestCases imported in tests.py. UserSettingsHolder
is not documented, it's an internal API, so it's safe to remove it fromdjango/db/models/sql/subqueries.py
.OneToOneField
is usually imported fromdjango.db.models
, so it's safe to remove it fromdjango/db/models/base.py
.- etc.
- It's generally unsafe to remove imports from
- I did not check
from ... import *
statements — they should be avoided in most cases anyway :)
- I proof read the whole patch before submitting it, and I'm rather confident that it's harmless for backwards compatibility. Obviously, the test suite still passes.
- It removes
django.contrib.admin.views.main.ORDER_TYPE_VAR
which is not used anywhere.
- It uses
functools.wraps
instead ofdjango.utils.unittest.compatibility.wraps
which was a Python 2.4 fallback, but it keeps the alias on which some third-party code must rely.
- When imports span several lines, I used parentheses for continuation instead of backslashes (except in our copy of unittest, which I didn't want to alter).
- I wrote consistently the fallback from cStringIO to StringIO and from cPickle to pickle, except in
django/contrib/gis/geos/tests/test_geos.py
where there is a bizarre comment.
Technical note: I did the cleanup with the check_imports.py
script available here: http://myks.org/en/projects/ because pylint dies on django's source (even after increasing the limit on the number of open files, I get AttributeError: 'NoneType' object has no attribute '_infer_name'
). This script uses static analysis, so it's not 100% reliable, but it works well in non-pathological cases.
- For the record, here is the list of what I did: K = kept, R = removed.
K django/conf/app_template/models.py: models K django/conf/project_template/urls.py: include, url R django/contrib/admin/templatetags/admin_list.py: ORDER_TYPE_VAR, SortedDict K django/contrib/admin/__init__.py: ACTION_CHECKBOX_NAME, AdminSite, AllValuesFieldListFilter, BooleanFieldListFilter, ChoicesFieldListFilter, DateFieldListFilter, FieldListFilter, HORIZONTAL, ListFilter, ModelAdmin, RelatedFieldListFilter, SimpleListFilter, StackedInline, TabularInline, VERTICAL R django/contrib/admindocs/views.py: templatetags R django/contrib/auth/backends.py: connection R django/contrib/auth/tests/auth_backends.py: warnings R django/contrib/auth/tests/tokens.py: AnonymousUser K django/contrib/auth/tests/__init__.py: AnonymousUserBackendTest, AuthContextProcessorTests, AuthenticationFormTest, BackendTest, BasicTestCase, ChangePasswordTest, GetDefaultUsernameTestCase, InActiveUserBackendTest, LoginRequiredTestCase, LoginTest, LoginURLSettings, LogoutTest, NoAnonymousUserBackendTest, NoBackendsTest, NoInActiveUserBackendTest, PasswordChangeFormTest, PasswordResetFormTest, PasswordResetTest, ProfileTestCase, RemoteUserCustomTest, RemoteUserNoCreateTest, RemoteUserTest, RowlevelBackendTest, SetPasswordFormTest, SignalTestCase, TestAuthPermissions, TokenGeneratorTest, UserChangeFormTest, UserCreationFormTest R django/contrib/auth/__init__.py: datetime K django/contrib/databrowse/__init__.py: DatabrowsePlugin, DatabrowseSite, ModelDatabrowse, site R django/contrib/formtools/preview.py: pickle, settings R django/contrib/formtools/utils.py: BooleanField R django/contrib/formtools/wizard/storage/session.py: UploadedFile K django/contrib/formtools/wizard/storage/__init__.py: BaseStorage, NoFileStorageConfigured R django/contrib/formtools/wizard/views.py: copy K django/contrib/formtools/wizard/__init__.py: FormWizard R django/contrib/gis/admin/options.py: settings K django/contrib/gis/admin/__init__.py: AdminSite, GeoModelAdmin, HORIZONTAL, ModelAdmin, OSMGeoAdmin, OpenLayersWidget, StackedInline, TabularInline, VERTICAL, autodiscover, site R django/contrib/gis/db/backends/base.py: settings R django/contrib/gis/db/backends/oracle/models.py: GeometryField R django/contrib/gis/db/models/aggregates.py: GeomField R django/contrib/gis/db/models/query.py: GeoWhereNode, GeometryField, Q R django/contrib/gis/db/models/sql/aggregates.py: GeomField R django/contrib/gis/db/models/sql/where.py: Field K django/contrib/gis/db/models/sql/__init__.py: AreaField, DistanceField, GeoQuery, GeoWhereNode, GeomField K django/contrib/gis/db/models/__init__.py: GeoManager, GeometryCollectionField, GeometryField, LineStringField, MultiLineStringField, MultiPointField, MultiPolygonField, PointField, PolygonField K django/contrib/gis/feeds.py: FeedDoesNotExist K django/contrib/gis/forms/__init__.py: GeometryField R django/contrib/gis/gdal/datasource.py: c_void_p R django/contrib/gis/gdal/feature.py: SpatialReference R django/contrib/gis/gdal/libgdal.py: sys R django/contrib/gis/gdal/prototypes/geom.py: c_char, c_ubyte, date, re R django/contrib/gis/gdal/srs.py: OGRException, c_void_p, re R django/contrib/gis/gdal/tests/test_driver.py: os, os.path K django/contrib/gis/gdal/__init__.py: CoordTransform, DataSource, Driver, Envelope, GDAL_VERSION, OGRException, OGRGeomType, OGRGeometry, OGRIndexError, SRSException, SpatialReference, check_err, gdal_full_version, gdal_release_date, gdal_version K django/contrib/gis/geometry/backend/geos.py: Geometry, GeometryException R django/contrib/gis/geos/base.py: GEOSIndexError R django/contrib/gis/geos/collections.py: GEOM_PTR, GEOSIndexError R django/contrib/gis/geos/geometry.py: c_size_t, re K django/contrib/gis/geos/io.py: WKBWriter, WKTWriter R django/contrib/gis/geos/polygon.py: GEOSIndexError R django/contrib/gis/geos/prototypes/geom.py: GEOS_PREPARE, PREPGEOM_PTR, c_uint R django/contrib/gis/geos/prototypes/topology.py: c_char_p K django/contrib/gis/geos/prototypes/__init__.py: create_collection, create_cs, create_linearring, create_linestring, create_point, create_polygon, cs_clone, cs_getdims, cs_getordinate, cs_getsize, cs_getx, cs_gety, cs_getz, cs_setordinate, cs_setx, cs_sety, cs_setz, destroy_geom, from_hex, from_wkb, from_wkt, geom_clone, geos_contains, geos_crosses, geos_disjoint, geos_equals, geos_equalsexact, geos_get_srid, geos_hasz, geos_intersects, geos_isempty, geos_isring, geos_issimple, geos_isvalid, geos_normalize, geos_overlaps, geos_relatepattern, geos_set_srid, geos_touches, geos_type, geos_typeid, geos_within, get_cs, get_dims, get_extring, get_geomn, get_intring, get_nrings, get_num_coords, get_num_geoms, to_hex, to_wkb, to_wkt R django/contrib/gis/geos/tests/test_geos.py: sys R django/contrib/gis/geos/tests/test_geos_mutation.py: copy R django/contrib/gis/geos/tests/test_io.py: ctypes K django/contrib/gis/geos/__init__.py: GEOSException, GEOSGeometry, GEOSIndexError, GEOS_PREPARE, GeometryCollection, LineString, LinearRing, MultiLineString, MultiPoint, MultiPolygon, Point, Polygon, WKBReader, WKBWriter, WKTReader, WKTWriter, fromfile, fromstr, geos_version, geos_version_info, hex_regex, wkt_regex R django/contrib/gis/management/commands/inspectdb.py: CommandError, make_option R django/contrib/gis/management/commands/ogrinspect.py: sys R django/contrib/gis/maps/google/gmap.py: GIcon, geos R django/contrib/gis/maps/google/zoom.py: cos K django/contrib/gis/maps/google/__init__.py: GEvent, GIcon, GMarker, GPolygon, GPolyline, GoogleMap, GoogleMapSet, GoogleZoom K django/contrib/gis/sitemaps/__init__.py: GeoRSSSitemap, KMLSitemap, KMZSitemap R django/contrib/gis/tests/distapp/tests.py: Decimal, Point, os R django/contrib/gis/tests/geoapp/feeds.py: Country, mysql K django/contrib/gis/tests/geoapp/tests.py: GeoFeedTest, GeoRegressionTests, GeoSitemapTest R django/contrib/gis/tests/geoapp/tests.py: Distance R django/contrib/gis/tests/geoapp/test_regress.py: no_oracle, no_postgis, os R django/contrib/gis/tests/geogapp/tests.py: A R django/contrib/gis/tests/layermap/tests.py: OGRException R django/contrib/gis/tests/test_spatialrefsys.py: mysql R django/contrib/gis/utils/layermapping.py: date, datetime R django/contrib/gis/utils/ogrinspect.py: OFTTime K django/contrib/gis/utils/__init__.py: GeoIP, GeoIPException, LayerMapError, LayerMapping, add_postgis_srs, add_srs_entry, mapping, ogrinfo, ogrinspect, precision_wkt, sample R django/contrib/localflavor/ar/forms.py: smart_unicode R django/contrib/localflavor/au/models.py: settings R django/contrib/localflavor/be/forms.py: EMPTY_VALUES, ValidationError, re R django/contrib/localflavor/in_/forms.py: re R django/contrib/localflavor/jp/forms.py: ValidationError R django/contrib/localflavor/kw/forms.py: RegexField R django/contrib/localflavor/pt/forms.py: Select R django/contrib/localflavor/ro/forms.py: re R django/contrib/localflavor/ru/forms.py: CharField, EMPTY_VALUES, ValidationError R django/contrib/localflavor/se/utils.py: re K django/contrib/localflavor/uk/uk_regions.py: ENGLAND_REGION_CHOICES, NORTHERN_IRELAND_REGION_CHOICES, SCOTTISH_REGION_CHOICES, WALES_REGION_CHOICES R django/contrib/localflavor/us/models.py: settings R django/contrib/localflavor/uy/forms.py: re R django/contrib/messages/api.py: lazy, memoize R django/contrib/messages/storage/cookie.py: constants R django/contrib/messages/tests/base.py: warnings R django/contrib/messages/tests/urls.py: redirect, render_to_response K django/contrib/messages/tests/__init__.py: CookieTest, FallbackTest, MiddlewareTest, SessionTest R django/contrib/sessions/backends/base.py: sys R django/contrib/sessions/backends/db.py: settings R django/contrib/sessions/models.py: base64, pickle R django/contrib/sitemaps/__init__.py: get_current_site R django/core/cache/backends/base.py: settings R django/core/cache/backends/memcached.py: importlib K django/core/cache/__init__.py: BaseCache, CacheKeyWarning K django/core/files/__init__.py: File R django/core/handlers/modpython.py: pformat, smart_str K django/core/handlers/modpython.py: settings R django/core/handlers/wsgi.py: pformat K django/core/handlers/wsgi.py: settings K django/core/mail/__init__.py: BadHeaderError, CachedDnsName, DEFAULT_ATTACHMENT_MIME_TYPE, DNS_NAME, SafeMIMEMultipart, SafeMIMEText, _SMTPConnection, forbid_multi_line_headers, make_msgid R django/core/management/commands/reset.py: settings K django/core/management/commands/shell.py: user K django/core/management/validation.py: Image, settings R django/core/serializers/base.py: datetime_safe, smart_str K django/core/serializers/__init__.py: yaml K django/core/servers/basehttp.py: FileWrapper K django/core/servers/fastcgi.py: flup R django/db/backends/postgresql_psycopg2/operations.py: re K django/db/backends/__init__.py: decimal K django/db/models/base.py: django.db.models.manager R django/db/models/base.py: OneToOneRel, types R django/db/models/deletion.py: GET_ITERATOR_CHUNK_SIZE R django/db/models/fields/files.py: ContentFile, UploadedFile, _, cache, curry, get_image_dimensions, settings R django/db/models/fields/related.py: settings, transaction, ugettext, ungettext R django/db/models/loading.py: imp R django/db/models/manager.py: settings R django/db/models/query.py: Aggregate, DateField, izip, signals R django/db/models/query_utils.py: SortedDict R django/db/models/sql/compiler.py: Model, connections K django/db/models/sql/query.py: InvalidQuery, select_related_descend R django/db/models/sql/subqueries.py: SQLEvaluator, connections R django/db/models/sql/where.py: QueryWrapper K django/db/models/sql/__init__.py: AND, EmptyResultSet, OR K django/db/models/__init__.py: CASCADE, DO_NOTHING, F, FileField, ForeignKey, ImageField, ImproperlyConfigured, Manager, ManyToManyField, ManyToManyRel, ManyToOneRel, Model, ObjectDoesNotExist, OneToOneField, OneToOneRel, PROTECT, ProtectedError, Q, SET, SET_DEFAULT, SET_NULL, SubfieldBase, connection, get_app, get_apps, get_model, get_models, register_models, settings, signals R django/db/transaction.py: settings, sys K django/db/__init__.py: IntegrityError K django/dispatch/__init__.py: Signal, receiver R django/forms/extras/widgets.py: time R django/forms/fields.py: EMPTY_VALUES, lazy, warnings K django/forms/util.py: ValidationError K django/forms/__init__.py: ValidationError R django/middleware/http.py: MiddlewareNotUsed K django/template/base.py: ContextPopException, RequestContext R django/template/base.py: Promise, imp R django/template/context.py: HttpRequest R django/template/debug.py: settings R django/template/defaulttags.py: Context, Variable R django/template/loaders/cached.py: ImproperlyConfigured, import_module R django/template/loader_tags.py: Context, TemplateDoesNotExist, Variable R django/template/smartif.py: operator K django/template/__init__.py: ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END, BLOCK_TAG_START, COMMENT_TAG_END, COMMENT_TAG_START, Context, ContextPopException, FILTER_ARGUMENT_SEPARATOR, FILTER_SEPARATOR, FilterExpression, InvalidTemplateLibrary, Lexer, Library, Node, NodeList, Origin, Parser, RequestContext, SINGLE_BRACE_END, SINGLE_BRACE_START, StringOrigin, TOKEN_BLOCK, TOKEN_COMMENT, TOKEN_TEXT, TOKEN_VAR, TRANSLATOR_COMMENT_MARK, Template, TemplateDoesNotExist, TemplateEncodingError, TemplateSyntaxError, TextNode, Token, TokenParser, UNKNOWN_SOURCE, VARIABLE_ATTRIBUTE_SEPARATOR, VARIABLE_TAG_END, VARIABLE_TAG_START, Variable, VariableDoesNotExist, VariableNode, add_to_builtins, builtins, compile_string, constant_string, filter_raw_string, filter_re, generic_tag_compiler, get_library, get_templatetags_modules, get_text_list, import_library, libraries, resolve_variable, tag_re, unescape_string_literal R django/templatetags/cache.py: force_unicode R django/templatetags/future.py: Node, Template, include_is_allowed, settings, smart_str R django/templatetags/i18n.py: VariableNode, force_unicode R django/templatetags/l10n.py: settings R django/test/client.py: transaction, urlunparse R django/test/testcases.py: UserSettingsHolder R django/test/utils.py: locmem, os, sys, time K django/test/__init__.py: Approximate, Client, RequestFactory, TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature K django/utils/autoreload.py: threading R django/utils/cache.py: HttpRequest R django/utils/functional.py: update_wrapper K django/utils/log.py: dictConfig R django/utils/log.py: sys R django/utils/timesince.py: time R django/utils/translation/trans_null.py: warnings R django/utils/translation/trans_real.py: warnings R django/utils/unittest/compatibility.py: wraps K django/utils/unittest/__init__.py: BaseTestSuite, FunctionTestCase, SkipTest, TestCase, TestLoader, TestProgram, TestResult, TestSuite, TextTestRunner, collector, defaultTestLoader, expectedFailure, findTestCases, getTestCaseNames, installHandler, main, main_, makeSuite, registerResult, removeHandler, removeResult, skip, skipIf, skipUnless R django/utils/version.py: os.path R django/views/debug.py: pformat R django/views/decorators/http.py: timedelta R django/views/generic/base.py: RequestContext, loader R django/views/generic/detail.py: re R django/views/generic/list.py: re K django/views/generic/__init__.py: ArchiveIndexView, CreateView, DateDetailView, DayArchiveView, DeleteView, DetailView, FormView, ListView, MonthArchiveView, RedirectView, TemplateView, TodayArchiveView, UpdateView, View, WeekArchiveView, YearArchiveView R tests/modeltests/basic/models.py: DEFAULT_DB_ALIAS, connection R tests/modeltests/basic/tests.py: DEFAULT_DB_ALIAS, connection, models R tests/modeltests/custom_pk/models.py: DEFAULT_DB_ALIAS, IntegrityError, settings, transaction R tests/modeltests/custom_pk/tests.py: DEFAULT_DB_ALIAS, settings R tests/modeltests/delete/models.py: IntegrityError K tests/modeltests/delete/tests.py: U R tests/modeltests/field_subclassing/fields.py: FieldError R tests/modeltests/field_subclassing/models.py: Small R tests/modeltests/files/models.py: ContentFile R tests/modeltests/files/tests.py: sys R tests/modeltests/fixtures/models.py: DEFAULT_DB_ALIAS, settings R tests/modeltests/fixtures/tests.py: Blog, Category, DEFAULT_DB_ALIAS, Person, settings, sys R tests/modeltests/fixtures_model_package/models/__init__.py: settings R tests/modeltests/force_insert_update/models.py: IntegrityError, transaction R tests/modeltests/get_object_or_404/models.py: Http404, get_list_or_404, get_object_or_404 R tests/modeltests/get_or_create/models.py: IntegrityError R tests/modeltests/lookup/models.py: DEFAULT_DB_ALIAS, connection, settings R tests/modeltests/lookup/tests.py: connection R tests/modeltests/m2m_through/tests.py: TestNoDefaultsOrNulls K tests/modeltests/model_forms/models.py: Image, _imaging R tests/modeltests/model_forms/models.py: os R tests/modeltests/model_formsets/tests.py: Editor K tests/modeltests/model_package/models/__init__.py: Article, Publication R tests/modeltests/mutually_referential/tests.py: Child R tests/modeltests/one_to_one/models.py: IntegrityError, transaction R tests/modeltests/pagination/tests.py: attrgetter R tests/modeltests/proxy_models/models.py: ContentType R tests/modeltests/proxy_model_inheritance/tests.py: Settings K tests/modeltests/test_client/models.py: Session R tests/modeltests/transactions/models.py: DEFAULT_DB_ALIAS R tests/modeltests/transactions/tests.py: DEFAULT_DB_ALIAS, settings, sys R tests/modeltests/unmanaged_models/tests.py: Unmanaged1 K tests/modeltests/update/tests.py: C R tests/modeltests/validation/models.py: TestCase R tests/modeltests/validation/tests.py: CustomMessagesTest, GetUniqueCheckTests, PerformUniqueChecksTest, TestModelsWithValidators R tests/modeltests/validation/validators.py: TestCase R tests/regressiontests/admin_filters/tests.py: with_statement K tests/regressiontests/admin_scripts/broken_app/models.py: modelz K tests/regressiontests/admin_scripts/complex_app/models/bar.py: foo K tests/regressiontests/admin_scripts/complex_app/models/__init__.py: Bar, Foo K tests/regressiontests/admin_scripts/simple_app/models.py: Bar K tests/regressiontests/admin_views/tests.py: PersonAdmin, admin R tests/regressiontests/bash_completion/management/commands/test_command.py: OptionParser, os, sys R tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py: CT, CommentForm, Site R tests/regressiontests/comment_tests/tests/feed_tests.py: get_warnings_state, restore_warnings_state, warnings R tests/regressiontests/comment_tests/tests/templatetag_tests.py: Comment R tests/regressiontests/csrf_tests/tests.py: warnings R tests/regressiontests/datatypes/tests.py: DEFAULT_DB_ALIAS, settings R tests/regressiontests/defer_regress/models.py: ContentType, connection, settings R tests/regressiontests/defer_regress/tests.py: connection, settings R tests/regressiontests/delete_regress/tests.py: Contact, connection R tests/regressiontests/expressions_regress/tests.py: models, settings R tests/regressiontests/file_storage/tests.py: File, _imaging R tests/regressiontests/fixtures_regress/models.py: DEFAULT_DB_ALIAS, connection, settings R tests/regressiontests/fixtures_regress/tests.py: sys R tests/regressiontests/forms/localflavor/cl.py: ValidationError K tests/regressiontests/forms/localflavortests.py: ARLocalFlavorTests, ATLocalFlavorTests, AULocalFlavorTests, AssertFieldOutputTests, BELocalFlavorTests, BRLocalFlavorTests, CALocalFlavorTests, CHLocalFlavorTests, CLLocalFlavorTests, CNLocalFlavorTests, CZLocalFlavorTests, DELocalFlavorTests, ESLocalFlavorTests, FILocalFlavorTests, FRLocalFlavorTests, GBLocalFlavorTests, GenericLocalFlavorTests, HRLocalFlavorTests, IDLocalFlavorTests, IELocalFlavorTests, ILLocalFlavorTests, ISLocalFlavorTests, ITLocalFlavorTests, JPLocalFlavorTests, KWLocalFlavorTests, NLLocalFlavorTests, PLLocalFlavorTests, PTLocalFlavorTests, ROLocalFlavorTests, RULocalFlavorTests, SELocalFlavorTests, SKLocalFlavorTests, TRLocalFlavorTests, USLocalFlavorTests, UYLocalFlavorTests, ZALocalFlavorTests R tests/regressiontests/forms/tests/fields.py: RadioFieldRenderer, time R tests/regressiontests/forms/tests/forms.py: Decimal, re, time R tests/regressiontests/forms/tests/models.py: ChoiceModel R tests/regressiontests/forms/tests/widgets.py: Decimal, re, time K tests/regressiontests/forms/tests/__init__.py: ARLocalFlavorTests, ATLocalFlavorTests, AULocalFlavorTests, AssertFieldOutputTests, BELocalFlavorTests, BRLocalFlavorTests, CALocalFlavorTests, CHLocalFlavorTests, CLLocalFlavorTests, CNLocalFlavorTests, CZLocalFlavorTests, DELocalFlavorTests, ESLocalFlavorTests, FILocalFlavorTests, FRLocalFlavorTests, FieldsTests, GBLocalFlavorTests, GenericLocalFlavorTests, HRLocalFlavorTests, IDLocalFlavorTests, IELocalFlavorTests, ILLocalFlavorTests, ISLocalFlavorTests, ITLocalFlavorTests, JPLocalFlavorTests, KWLocalFlavorTests, NLLocalFlavorTests, PLLocalFlavorTests, PTLocalFlavorTests, ROLocalFlavorTests, RULocalFlavorTests, SELocalFlavorTests, SKLocalFlavorTests, TRLocalFlavorTests, TestFieldWithValidators, USLocalFlavorTests, UYLocalFlavorTests, ZALocalFlavorTests R tests/regressiontests/generic_relations_regress/tests.py: ContentType R tests/regressiontests/generic_views/base.py: simplejson R tests/regressiontests/generic_views/dates.py: random R tests/regressiontests/generic_views/list.py: CustomPaginator K tests/regressiontests/generic_views/tests.py: ArchiveIndexViewTests, CreateViewTests, DateDetailViewTests, DayArchiveViewTests, DeleteViewTests, DetailViewTest, ListViewTests, ModelFormMixinTests, MonthArchiveViewTests, RedirectViewTest, TemplateViewTest, UpdateViewTests, ViewTest, WeekArchiveViewTests, YearArchiveViewTests R tests/regressiontests/i18n/forms.py: template K tests/regressiontests/i18n/tests.py: DeprecationWarningTests R tests/regressiontests/i18n/tests.py: sys R tests/regressiontests/introspection/tests.py: DEFAULT_DB_ALIAS, settings R tests/regressiontests/localflavor/tests.py: TestCase, unittest R tests/regressiontests/m2m_through_regress/models.py: datetime, management K tests/regressiontests/many_to_one_regress/tests.py: Second R tests/regressiontests/max_lengths/tests.py: DatabaseError R tests/regressiontests/middleware_exceptions/models.py: models R tests/regressiontests/modeladmin/models.py: date R tests/regressiontests/model_fields/imagefield.py: ContentFile K tests/regressiontests/model_fields/models.py: _imaging K tests/regressiontests/model_fields/tests.py: FieldFile, ImageFieldDimensionsFirstTests, ImageFieldNoDimensionsTests, ImageFieldOneDimensionTests, ImageFieldTests, ImageFieldTwoDimensionsTests, ImageFieldUsingFileTests, TwoImageFieldTests, forms R tests/regressiontests/multiple_database/models.py: settings K tests/regressiontests/multiple_database/tests.py: Article, article_using R tests/regressiontests/multiple_database/tests.py: ConnectionRouter, sys R tests/regressiontests/select_related_onetoone/tests.py: db, settings R tests/regressiontests/serializers_regress/tests.py: DEFAULT_DB_ALIAS, management, settings, transaction R tests/regressiontests/settings_tests/tests.py: skipIf, sys R tests/regressiontests/signals_regress/tests.py: StringIO, sys R tests/regressiontests/syndication/tests.py: datetime, warnings R tests/regressiontests/templates/custom.py: with_statement R tests/regressiontests/templates/loaders.py: get_warnings_state, restore_warnings_state, warnings R tests/regressiontests/templates/response.py: RequestContext R tests/regressiontests/templates/smartif.py: Literal K tests/regressiontests/templates/templatetags/broken_tag.py: Xtemplate K tests/regressiontests/templates/tests.py: ContextTests, CustomFilterTests, CustomTagTests, LocalTimezone, NodelistTest, ParserTests, UnicodeTests, _ R tests/regressiontests/test_utils/tests.py: skipIfDBFeature, sys R tests/regressiontests/urlpatterns_reverse/middleware.py: set_urlconf K tests/regressiontests/urlpatterns_reverse/tests.py: urlconf_inner R tests/regressiontests/utils/jslex.py: difflib K tests/regressiontests/utils/module_loading.py: types K tests/regressiontests/utils/test_module/bad_module.py: a_package_name_that_does_not_exist R tests/regressiontests/views/tests/debug.py: ImproperlyConfigured R tests/regressiontests/views/tests/defaults.py: path, settings
by , 13 years ago
Attachment: | 16225.patch added |
---|
comment:6 by , 13 years ago
Feedback I gave jezdez on IRC:
[12:04 PM] <Alex_Gaynor> jezdez: o_O damn, 100 seconds, I literally don't beleive that, also spataliate change makes it uglies [12:05 PM] <Alex_Gaynor> test_geom.py should probably move the import out of hte function [12:10 PM] <Alex_Gaynor> jezdez: also probably shouldn't mess with django.utils.unittest
comment:7 by , 13 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
This patch isn't difficult; it's a just long and painful to write and maintain. Written one month ago, it's already outdated (it doesn't apply to trunk).
I'm ready to update it and take into account Alex's comments. However, before I spend a few hours on this, I'd like to know that a core dev is going to take a look reasonably soon afterwards... Otherwise it's a complete waste of time... Just waiting for your "thumbs up" :)
comment:10 by , 13 years ago
Patch needs improvement: | unset |
---|
I started from your last patch and edited it until it applied properly.
I moved all imports in django/contrib/gis/gdal/tests/test_geom.py
to the beginning of the file. I reverted the changes in django/utils/unittest
. I didn't touch django/contrib/gis/db/backends/spatialite/base.py
, even if it's ugly, because fixing import *
abuse is beyond the scope of this ticket. Let's open another ticket if you think it's important.
I re-checked for unused imports, applying the same methodology described in comment 5 above, and removed several imports that were used one month ago but no longer are.
I ran the test suite (under sqlite) to check for imports that were unused one month ago, but now are used. This happened at least as a consequence of https://code.djangoproject.com/changeset/16495/django/trunk/django/contrib/localflavor/in_/forms.py
Finally I proof-read the whole patch.
Here's the detail of what I have changed since the first patch, with this new code:
K+ = I had removed it, you kept it, I didn't remove it again (because I was wrong the first time, or because I'm not sure)
R+ = I had removed it, you kept it, I removed it again because I'm really, really sure it's unused
You may want to check them specially.
R django/contrib/admin/templatetags/admin_list.py: settings R django/contrib/admin/widgets.py: settings R django/contrib/auth/forms.py: Context R django/contrib/auth/tests/forms.py: settings R django/contrib/formtools/wizard/tests/namedwizardtests/tests.py: os, settings R django/contrib/gis/admin/widgets.py: settings K+ django/contrib/gis/db/models/aggregates.py: GeomField R+ django/contrib/gis/tests/geoapp/test_regress.py: os R django/contrib/sitemaps/views.py: HttpResponse, smart_str R django/core/handlers/wsgi.py: socket R django/core/servers/basehttp.py: ImproperlyConfigured K django/db/backends/dummy/base.py: decimal K django/db/backends/mysql/base.py: decimal R django/db/models/fields/__init__.py: is_valid_ipv6_address K+ django/db/models/sql/compiler.py: Model, connections K+ django/forms/fields.py: EMPTY_VALUES K+ django/utils/functional.py: update_wrapper K django/utils/unittest/compatibility.py: wraps R tests/modeltests/many_to_one/tests.py: FieldError K+ tests/modeltests/validation/tests.py: CustomMessagesTest, GetUniqueCheckTests, PerformUniqueChecksTest, TestModelsWithValidators R tests/modeltests/validation/test_unique.py: connection, settings K+ tests/regressiontests/file_storage/tests.py: _imaging R tests/regressiontests/file_uploads/tests.py: MultiPartParserError R tests/regressiontests/forms/localflavor/in_.py: warnings R tests/regressiontests/forms/tests/media.py: settings R tests/regressiontests/i18n/patterns/urls/namespace.py: include R tests/regressiontests/i18n/patterns/urls/wrong.py: patterns R tests/regressiontests/i18n/patterns/urls/wrong_namespace.py: include K tests/regressiontests/urlpatterns_reverse/erroneous_views_module.py: non_existent K tests/regressiontests/urlpatterns_reverse/views.py: non_existent
This should be fixed carefully because some apparently unused imports provide backwards compatibility, when functions or classes were moved from one module to another.