-
Notifications
You must be signed in to change notification settings - Fork 3
Fix importing async classes #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Previously we were unable to import AsyncSearch, AsyncMultiSearch, AsyncUpdateByQuery because the import of AsyncMapping was failing. As @sethmlarson wishes to deprecate Mapping (and never implement AsyncMapping) in 7.x and remove it in 8.x so we might as well remove the import for AsyncMapping, but after @sethmlarson approves this change.
The linting error (isort) are lines of code I hadn't changed. diff --git a/elasticsearch_dsl/__init__.py b/elasticsearch_dsl/__init__.py
index 26fe8aa..c258341 100644
--- a/elasticsearch_dsl/__init__.py
+++ b/elasticsearch_dsl/__init__.py
@@ -17,64 +17,21 @@
from . import connections
from .aggs import A
-from .analysis import analyzer, char_filter, normalizer, token_filter, tokenizer
+from .analysis import (analyzer, char_filter, normalizer, token_filter,
+ tokenizer)
from .document import Document, InnerDoc, MetaField
-from .exceptions import (
- ElasticsearchDslException,
- IllegalOperation,
- UnknownDslObject,
- ValidationException,
-)
-from .faceted_search import (
- DateHistogramFacet,
- Facet,
- FacetedResponse,
- FacetedSearch,
- HistogramFacet,
- NestedFacet,
- RangeFacet,
- TermsFacet,
-)
-from .field import (
- Binary,
- Boolean,
- Byte,
- Completion,
- CustomField,
- Date,
- DateRange,
- DenseVector,
- Double,
- DoubleRange,
- Field,
- Float,
- FloatRange,
- GeoPoint,
- GeoShape,
- HalfFloat,
- Integer,
- IntegerRange,
- Ip,
- IpRange,
- Join,
- Keyword,
- Long,
- LongRange,
- Murmur3,
- Nested,
- Object,
- Percolator,
- RangeField,
- RankFeature,
- RankFeatures,
- ScaledFloat,
- SearchAsYouType,
- Short,
- SparseVector,
- Text,
- TokenCount,
- construct_field,
-)
+from .exceptions import (ElasticsearchDslException, IllegalOperation,
+ UnknownDslObject, ValidationException)
+from .faceted_search import (DateHistogramFacet, Facet, FacetedResponse,
+ FacetedSearch, HistogramFacet, NestedFacet,
+ RangeFacet, TermsFacet)
+from .field import (Binary, Boolean, Byte, Completion, CustomField, Date,
+ DateRange, DenseVector, Double, DoubleRange, Field, Float,
+ FloatRange, GeoPoint, GeoShape, HalfFloat, Integer,
+ IntegerRange, Ip, IpRange, Join, Keyword, Long, LongRange,
+ Murmur3, Nested, Object, Percolator, RangeField,
+ RankFeature, RankFeatures, ScaledFloat, SearchAsYouType,
+ Short, SparseVector, Text, TokenCount, construct_field)
from .function import SF
from .index import Index, IndexTemplate
from .mapping import Mapping
Should I run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment for you, I appreciate you helping me out :)
elasticsearch_dsl/__init__.py
Outdated
from .search import AsyncMultiSearch, AsyncSearch # noqa: F401 | ||
from .update_by_query import AsyncUpdateByQuery # noqa: F401 | ||
from .mapping import AsyncMapping # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since AsyncMapping
doesn't exist you can remove this import.
@@ -33,7 +33,7 @@ | |||
] | |||
|
|||
try: | |||
from ._sync import AsyncMultiSearch, AsyncSearch # noqa: F401 | |||
from ._async import AsyncMultiSearch, AsyncSearch # noqa: F401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch here, thank you.
I use |
No problem. I wanted to use async elasticsearch_dsl anyway. Thank you for maintaining the package |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Previously we were unable to import AsyncSearch, AsyncMultiSearch, AsyncUpdateByQuery because the import of AsyncMapping was failing.
resulting failing imports
After this small fix we can successfully import every class except
AsyncMapping
(as it is not implemented)As @sethmlarson wishes to deprecate Mapping (and never implement AsyncMapping) in 7.x and remove it in 8.x so we might as well remove the import for AsyncMapping, but after @sethmlarson approves this change.