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
Add python_version marker constraint in setup.py #367
Comments
I can make pull request that adds this constraint or I can add poetry as your dependency manager. Poetry would be really nice because it's easier to maintain than |
I've created a workaround in my project so this issue is not so important for me, but for someone it might be useful. |
If you could issue a PR pinning the python version that would be awesome! As for the poetry i was thinking about it for some time already, i use poetry in other projects and i like it. So if you are willing to make the necessary changes and issue another pr (so i can test deploys etc) that would be even more awesome! 😁 |
Ok. The I'll try to make it in the best way possible. 🌟 Thanks you for your fast reply. 🌟 |
I've got some questions. I've created pyproject.toml with minimum python version "^3.6.2" is it ok? Also I faced an issue that black formats code and flake finds errors. Here is the log of my actions with output. |
Yes, up 3.6.2 if fine. As for the flake8 check the config in .flake8 file I specifically disabled some checks. The amount of black reformatted files seems suspicious too, what is the line length setting? (should be 88) |
I haven't change the any config file. Here is some diffs with before and after black: -def post_save(senders: Union[Type["Model"], List[Type["Model"]]],) -> Callable:
+def post_save(
+ senders: Union[Type["Model"], List[Type["Model"]]],
+) -> Callable:
"""
Connect given function to all senders for post_save signal.
@@ -54,7 +56,9 @@ def post_save(senders: Union[Type["Model"], List[Type["Model"]]],) -> Callable:
return receiver(signal="post_save", senders=senders)
-def post_update(senders: Union[Type["Model"], List[Type["Model"]]],) -> Callable:
+def post_update(
+ senders: Union[Type["Model"], List[Type["Model"]]],
+) -> Callable:
"""
Connect given function to all senders for post_update signal.
@@ -67,7 +71,9 @@ def post_update(senders: Union[Type["Model"], List[Type["Model"]]],) -> Callable
return receiver(signal="post_update", senders=senders)
-def post_delete(senders: Union[Type["Model"], List[Type["Model"]]],) -> Callable:
+def post_delete(
+ senders: Union[Type["Model"], List[Type["Model"]]],
+) -> Callable:
"""
Connect given function to all senders for post_delete signal.
@@ -43,8 +43,8 @@ class NoMatch(AsyncOrmException):
class MultipleMatches(AsyncOrmException):
"""
- Raised for database queries that should return one row (i.e. get, first etc.)
- but has multiple matching results in response.
+ Raised for database queries that should return one row (i.e. get, first etc.)
+ but has multiple matching results in response.
"""
pass
@@ -52,11 +52,11 @@ class MultipleMatches(AsyncOrmException):
class QueryDefinitionError(AsyncOrmException):
"""
- Raised for errors in query definition:
+ Raised for errors in query definition:
- * using contains or icontains filter with instance of the Model
- * using Queryset.update() without filter and setting each flag to True
- * using Queryset.delete() without filter and setting each flag to True
+ * using contains or icontains filter with instance of the Model
+ * using Queryset.update() without filter and setting each flag to True
+ * using Queryset.delete() without filter and setting each flag to True
"""
pass I guess the game changer for function is a comma after the function parameters. Like def test(a: int,) -> None: # Would be refformated
...
def test(a: int) -> None: # Wouldn't be refformated
... But why does it reformat docstring like this? |
I think string-related handling was experimental and was enabled by default in the newest version of black. but changes like those seem weird as it was black which inserted those commas in the first place :)
|
It's looks really strange. |
You can provide the '-C" parameter to the black, in order to exclude magic commas and it will remove all trailing commas. Like this: +++ ormar/relations/querysetproxy.py 2021-10-08 09:26:28.502277 +0000
@@ -292,11 +292,11 @@
:type exclude_through: bool
:param fields: field name or list of field names to extract from db
:type fields: Union[List, str, Set, Dict]
"""
return await self.queryset.values(
- fields=fields, exclude_through=exclude_through,
+ fields=fields, exclude_through=exclude_through
)
async def values_list(
self,
fields: Union[List, str, Set, Dict] = None,
@@ -477,12 +477,11 @@
children = await self.queryset.all()
for child in children:
await child.update(**kwargs) # type: ignore
if self.type_ == ormar.RelationType.MULTIPLE and through_kwargs:
await self.update_through_instance(
- child=child, # type: ignore
- **through_kwargs,
+ child=child, **through_kwargs # type: ignore
)
return len(children)
async def get_or_create(self, *args: Any, **kwargs: Any) -> "T":
"""
would reformat ormar/relations/querysetproxy.py
--- ormar/queryset/queryset.py 2021-10-08 09:25:14.915843 +0000
+++ ormar/queryset/queryset.py 2021-10-08 09:26:28.599002 +0000
@@ -245,11 +245,11 @@
:rtype: sqlalchemy.Table
"""
return self.model_meta.table
def build_select_expression(
- self, limit: int = None, offset: int = None, order_bys: List = None,
+ self, limit: int = None, offset: int = None, order_bys: List = None
) -> sqlalchemy.sql.select:
"""
Constructs the actual database query used in the QuerySet.
If any of the params is not passed the QuerySet own value is used.
@@ -376,11 +376,11 @@
rel._access_chain if isinstance(rel, FieldAccessor) else rel
for rel in related
]
related = sorted(list(set(list(self._select_related) + related)))
- return self.rebuild_self(select_related=related,)
+ return self.rebuild_self(select_related=related)
def select_all(self, follow: bool = False) -> "QuerySet[T]":
"""
By default adds only directly related models.
@@ -402,11 +402,11 @@
:rtype: Model
"""
relations = list(self.model.extract_related_names())
if follow:
relations = self.model._iterate_related_models()
- return self.rebuild_self(select_related=relations,)
+ return self.rebuild_self(select_related=relations)
def prefetch_related(
self, related: Union[List, str, FieldAccessor]
) -> "QuerySet[T]":
"""
@@ -432,11 +432,11 @@
rel._access_chain if isinstance(rel, FieldAccessor) else rel
for rel in related
]
related = list(set(list(self._prefetch_related) + related))
- return self.rebuild_self(prefetch_related=related,)
+ return self.rebuild_self(prefetch_related=related)
def fields(
self, columns: Union[List, str, Set, Dict], _is_exclude: bool = False
) -> "QuerySet[T]":
""" |
Yeah I see this is something quite new: psf/black#1288 Or if you remove -C after first call black adds those commas back? |
I ran black twice with "-C" and without "-C" flag. It won't add those command back. |
Can you please check the request #368? I can close it and modify |
The request #369 adds python_version marker as a fast fix to this problem. |
Describe the bug
I've found a dependency resolution problem when installing ormar with black using poetry.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Versions (please complete the following information):
poetry
^1.1.11ormar
^0.10.20black
^21.9b0Possible solution
Since you use typing_extensions only for providing
Protocol
andLiteral
, you may add constraint to avoid this issue.The solution is to specify the typing_extension version in your setup.py as following:
Additional context
This issue is crucial for me, since I want to integrate your super cool library in my project generator. It uses black by default, but I can't get it work with your library because of this issue.
Thanks in advance.
The text was updated successfully, but these errors were encountered: