Skip to content
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

Fixed #35682 -- Made Docstring updates in BaseDetailView and BaseList… #18493

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

YashRaj1506
Copy link

@YashRaj1506 YashRaj1506 commented Aug 18, 2024

…View.

Trac ticket number

ticket-35682

Branch description

Majority of the BaseView's like BaseUpdateView, BaseCreateView and other's has specified in their docstring and their docs that
"Using this base class requires subclassing to provide a response mixin." but in BaseListView and BaseDetailView where it is needed to , it is not mentioned inside the docstring but it is mentioned in their docs. So i added the same statement "Using this base class requires subclassing to provide a response mixin." inside the docstring of both BaseListView and BaseDetailView.

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.
  • I have attached screenshots in both light and dark modes for any UI changes.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello! Thank you for your contribution 💪

As it's your first contribution be sure to check out the patch review checklist.

If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!

If you have any design or process questions then you can ask in the Django forum.

Welcome aboard ⛵️!

@YashRaj1506
Copy link
Author

YashRaj1506 commented Aug 18, 2024

@felixxm hey there, i am a new contributor here and this is my first PR, i wanted to ask why the two test cases are failing here. The two are Linters flake8 and black.

@cliff688
Copy link
Contributor

cliff688 commented Aug 18, 2024

Hello @YashRaj1506!
You will find the details of the failures in your file changes

@YashRaj1506
Copy link
Author

Hello @YashRaj1506! You will find the details of the failures in your file changes

Thank you i got it now.

django/views/generic/list.py Outdated Show resolved Hide resolved
django/views/generic/detail.py Outdated Show resolved Hide resolved
Copy link
Contributor

@cliff688 cliff688 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For completeness' sake, I suggest you go through the BaseViews in dates.py as well.

By the way, if a docstring already mentions that a BaseView is an abstract base class, it is reduntant to mention that it requires subclassing. In those cases I suggest: Requires a response mixin.

@YashRaj1506
Copy link
Author

YashRaj1506 commented Aug 20, 2024

For completeness' sake, I suggest you go through the BaseViews in dates.py as well.

By the way, if a docstring already mentions that a BaseView is an abstract base class, it is reduntant to mention that it requires subclassing. In those cases I suggest: Requires a response mixin.

Yeah i missed dates.py, i will commit the changes, and on the second thing you mentioned. UPDATE: I made the changes see if you want any other changes.

Copy link
Member

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording should probably be consistent across the three cases.

Copy link
Contributor

@cliff688 cliff688 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You left out many other Base Views in dates.py that neglect to mention their subclassing requirements in docstrings.

@YashRaj1506
Copy link
Author

You left out many other Base Views in dates.py that neglect to mention their subclassing requirements in docstrings.

oh my bad will go work over it, Will read the whole dates.py

@YashRaj1506
Copy link
Author

The wording should probably be consistent across the three cases.

Just to clarify, You mean to say the three places i made changes at, should have the same "this class is meant to be subclassed" message? As i added the response Mixin message in the third dates.py base class?

@YashRaj1506
Copy link
Author

You left out many other Base Views in dates.py that neglect to mention their subclassing requirements in docstrings.

For the docstrings which don't mention they are a abstract class like
"BaseMonthArchiveView", ""BaseDayArchiveView" and others, they just specify their functionalities of what it does. Should i add infront of it that "A abstract base class which does action-it-does. Requires a Response Mixin"? it will be enough ig.

@cliff688
Copy link
Contributor

For the docstrings which don't mention they are a abstract class like "BaseMonthArchiveView", ""BaseDayArchiveView" and others, they just specify their functionalities of what it does. Should i add infront of it that "A abstract base class which does action-it-does. Requires a Response Mixin"? it will be enough ig.

I think it's better if we use consistent wording for all Base Views with unclear docstrings. Like so:

class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView):
    """
    Base view for displaying a list of objects published in a given month.

    Requires a response mixin.
    """

Let me know what you think.

@YashRaj1506
Copy link
Author

For the docstrings which don't mention they are a abstract class like "BaseMonthArchiveView", ""BaseDayArchiveView" and others, they just specify their functionalities of what it does. Should i add infront of it that "A abstract base class which does action-it-does. Requires a Response Mixin"? it will be enough ig.

I think it's better if we use consistent wording for all Base Views with unclear docstrings. Like so:

class BaseMonthArchiveView(YearMixin, MonthMixin, BaseDateListView):
    """
    Base view for displaying a list of objects published in a given month.

    Requires a response mixin.
    """

Let me know what you think.

The edit that i made on the docstring (yet to commit) looks like this only, I think this would be good enough to go with. I will make the following changes and will tag you if i find something better.

As it was mentioned in suggestions, that the wording should be  same everywhere for the base views, i made the changes accordingly.
fixed flake8 at line 654.
@YashRaj1506
Copy link
Author

@carltongibson @cliff688 I have made the changes accordingly, keeping both of your suggestions in mind. Will this commit be enough or do i need to make any other changes? Do let me know i will work on it.

Copy link
Contributor

@cliff688 cliff688 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Using this base class requires subclassing to provide a response mixin. is wordier than Requires a response mixin.
What do you think.

@@ -625,8 651,10 @@ class TodayArchiveView(MultipleObjectTemplateResponseMixin, BaseTodayArchiveView

class BaseDateDetailView(YearMixin, MonthMixin, DayMixin, DateMixin, BaseDetailView):
"""
Detail view of a single object on a single date; this differs from the
standard DetailView by accepting a year/month/day in the URL.
A base view for Detail view of a single object on a single date; this differs from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A base view for Detail view of a single object on a single date; this differs from
A base detail view for a single object on a single date; this differs from
the standard DetailView by accepting year/month/day in the URL.

@@ -300,7 300,11 @@ def _make_single_date_lookup(self, date):


class BaseDateListView(MultipleObjectMixin, DateMixin, View):
"""Abstract base class for date-based views displaying a list of objects."""
"""
A base view for date-based views displaying a list of objects.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous line was probably clearer and more concise:

Suggested change
A base view for date-based views displaying a list of objects.
Abstract base class for date-based views displaying a list of objects.

or maybe

Suggested change
A base view for date-based views displaying a list of objects.
Base class for date-based views displaying a list of objects.

@YashRaj1506
Copy link
Author

I think Using this base class requires subclassing to provide a response mixin. is wordier than Requires a response mixin. What do you think.

It was but as earlier @carltongibson quoted that all the base views should have a consistency in the wordings, i considered that and made the changes. I will make the minor sentence changes you recommended as those are important. Rest what do you think , Should we turn it back? eitherways it gives a more concrete message.

@cliff688
Copy link
Contributor

It was but as earlier @carltongibson quoted that all the base views should have a consistency in the wordings, i considered that and made the changes.

Indeed... I also agree that the wording should be consistent💯. Even so, there is still the question of which wording is better🤔. And this is what I meant for us to discuss...
Feel free to keep whichever one you prefer, but then the choice is better when it's consciously consisered, I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants