Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#27145 closed Cleanup/optimization (fixed)

Discrepenacy between documentation and docstring for Storage.save method

Reported by: Sergei Zh Owned by: nobody
Component: Documentation Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Docstring for django.core.files.storage.Storage.save method says:

        """
        Saves new content to the file specified by name. The content should be
        a proper File object or any python file-like object, ready to be read
        from the beginning.
        """

But in docs provided next description for content attribute

The content argument must be an instance of django.core.files.File or of a subclass of File.

What about to update docs or add additional check in save method?

Change History (5)

comment:1 by Baptiste Mispelon, 8 years ago

Component: File uploads/storageDocumentation
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

Hi,

I agree with you, there is a discrepancy here between the docstring and the documentation and we should correct that.

I have a feeling that the docstring might be the one that needs fixing but I am not sure. This will have to be determined.

Thanks.

comment:2 by Tim Graham, 8 years ago

Has patch: set
Summary: Misunderstanding beetween documentation and docstring for Storage.save methodDiscrepenacy between documentation and docstring for Storage.save method

Looks like 664855b74e1f417384dc7aef35a3df5f86db52d6 added the option to use a file-like object but the docs weren't updated. Does this look like enough?

  • docs/ref/files/storage.txt

    diff --git a/docs/ref/files/storage.txt b/docs/ref/files/storage.txt
    index dd06701..38f0135 100644
    a b The ``Storage`` class  
    221221        :meth:`get_available_name`.
    222222
    223223        The ``content`` argument must be an instance of
    224         :class:`django.core.files.File` or of a subclass of
    225         :class:`~django.core.files.File`.
     224        :class:`django.core.files.File` or a file-like object.
    226225
    227226    .. method:: size(name)

Alternatively, maybe "or a file-like object that can be wrapped in File".

Last edited 8 years ago by Tim Graham (previous) (diff)

comment:3 by Baptiste Mispelon, 8 years ago

Triage Stage: AcceptedReady for checkin

The proposed patch seems good to me.

Thanks.

comment:4 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: newclosed

In 3f16e4df:

Fixed #27145 -- Updated Storage.save() docs for refs #18899.

comment:5 by Tim Graham <timograham@…>, 8 years ago

In f79dce16:

[1.10.x] Fixed #27145 -- Updated Storage.save() docs for refs #18899.

Backport of 3f16e4df494dc9143d110b886c8e8608f9d2b584 from master

Note: See TracTickets for help on using tickets.
Back to Top