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

Make setters private (rework of #69) #107

Merged
merged 7 commits into from Mar 25, 2015
Merged

Make setters private (rework of #69) #107

merged 7 commits into from Mar 25, 2015

Conversation

@glennmatthews
Copy link
Contributor

@glennmatthews glennmatthews commented Feb 18, 2015

Rework #69 to patch cleanly with latest master code.

Example code:

class COTInfo(COTGenericSubmodule):

    """Display VM information string."""

    def __init__(self, UI):
        """Instantiate this submodule with the given UI."""
        super(COTInfo, self).__init__(UI)
        self._package_list = None
        self._verbosity = None

    @property
    def package_list(self):
        """List of VM definitions to get information for."""
        return self._package_list

    @package_list.setter
    def package_list(self, value):
        for package in value:
            if not os.path.exists(package):
                raise InvalidInputError("Specified package {0} does not exist!"
                                        .format(package))
        self._package_list = value

    @property
    def verbosity(self):
        """Verbosity of information displayed."""
        return self._verbosity

    @verbosity.setter
    def verbosity(self, value):
        if value not in ['brief', 'verbose', None]:
            raise InvalidInputError(
                "Verbosity must be 'brief', 'verbose', or None")
        self._verbosity = value

Before - pep257 wants docstrings on setter methods:

> pep257 COT/info.py
COT/info.py:45 in public method `package_list`:
        D102: Docstring missing
COT/info.py:58 in public method `verbosity`:
        D102: Docstring missing
>

After - setters are ignored:

> /pep257 ../cot/COT/info.py
>
@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Mar 3, 2015

This is technically an incomplete fix, as the same issue can exist with functions decorated as @foo.deleter - I'll look into that when I get a chance but in my experience setters are more common so this is valuable even in its current form.

@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Mar 3, 2015

Looks like the original implementation covered deleters as well. I've just added a unit test to confirm this.

@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Mar 17, 2015

Anything I can do to move this along? I can't adopt pep257 for my project without this fix:

$ pep257 COT
COT/add_disk.py:80 in public method `disk_image`:
        D102: Missing docstring in public method
COT/add_disk.py:96 in public method `address`:
        D102: Missing docstring in public method
COT/add_disk.py:111 in public method `controller`:
        D102: Missing docstring in public method
COT/add_file.py:62 in public method `file`:
        D102: Missing docstring in public method
COT/deploy.py:106 in public method `hypervisor`:
        D102: Missing docstring in public method
COT/deploy.py:121 in public method `configuration`:
        D102: Missing docstring in public method
COT/deploy.py:137 in public method `power_on`:
        D102: Missing docstring in public method
COT/deploy.py:260 in public method `ovftool_args`:
        D102: Missing docstring in public method
COT/edit_hardware.py:94 in public method `cpus`:
        D102: Missing docstring in public method
COT/edit_hardware.py:110 in public method `memory`:
        D102: Missing docstring in public method
COT/edit_hardware.py:150 in public method `nics`:
        D102: Missing docstring in public method
COT/edit_hardware.py:164 in public method `nic_type`:
        D102: Missing docstring in public method
COT/edit_hardware.py:174 in public method `serial_ports`:
        D102: Missing docstring in public method
COT/edit_properties.py:66 in public method `config_file`:
        D102: Missing docstring in public method
COT/edit_properties.py:78 in public method `properties`:
        D102: Missing docstring in public method
COT/help.py:52 in public method `subcommand`:
        D102: Missing docstring in public method
COT/info.py:53 in public method `package_list`:
        D102: Missing docstring in public method
COT/info.py:66 in public method `verbosity`:
        D102: Missing docstring in public method
COT/inject_config.py:62 in public method `config_file`:
        D102: Missing docstring in public method
COT/inject_config.py:84 in public method `secondary_config_file`:
        D102: Missing docstring in public method
COT/ovf.py:371 in public method `output_file`:
        D102: Missing docstring in public method
COT/ovf.py:491 in public method `system_types`:
        D102: Missing docstring in public method
COT/ovf.py:514 in public method `version_short`:
        D102: Missing docstring in public method
COT/submodule.py:131 in public method `package`:
        D102: Missing docstring in public method
COT/submodule.py:184 in public method `package`:
        D102: Missing docstring in public method
COT/submodule.py:206 in public method `output`:
        D102: Missing docstring in public method
COT/vm_description.py:121 in public method `output_file`:
        D102: Missing docstring in public method
COT/vm_description.py:180 in public method `system_types`:
        D102: Missing docstring in public method
COT/vm_description.py:189 in public method `version_short`:
        D102: Missing docstring in public method
COT/vm_description.py:198 in public method `version_long`:
        D102: Missing docstring in public method
COT/helpers/helper.py:220 in public method `name`:
        D102: Missing docstring in public method

@Nurdok
Copy link
Member

@Nurdok Nurdok commented Mar 18, 2015

I will take a look at it over the weekend. Sorry for the delay.
On Mar 17, 2015 11:00 PM, "Glenn Matthews" notifications@github.com wrote:

Anything I can do to move this along? I can't adopt pep257 for my project
without this fix:

$ pep257 COT
COT/add_disk.py:80 in public method disk_image:
D102: Missing docstring in public method
COT/add_disk.py:96 in public method address:
D102: Missing docstring in public method
COT/add_disk.py:111 in public method controller:
D102: Missing docstring in public method
COT/add_file.py:62 in public method file:
D102: Missing docstring in public method
COT/deploy.py:106 in public method hypervisor:
D102: Missing docstring in public method
COT/deploy.py:121 in public method configuration:
D102: Missing docstring in public method
COT/deploy.py:137 in public method power_on:
D102: Missing docstring in public method
COT/deploy.py:260 in public method ovftool_args:
D102: Missing docstring in public method
COT/edit_hardware.py:94 in public method cpus:
D102: Missing docstring in public method
COT/edit_hardware.py:110 in public method memory:
D102: Missing docstring in public method
COT/edit_hardware.py:150 in public method nics:
D102: Missing docstring in public method
COT/edit_hardware.py:164 in public method nic_type:
D102: Missing docstring in public method
COT/edit_hardware.py:174 in public method serial_ports:
D102: Missing docstring in public method
COT/edit_properties.py:66 in public method config_file:
D102: Missing docstring in public method
COT/edit_properties.py:78 in public method properties:
D102: Missing docstring in public method
COT/help.py:52 in public method subcommand:
D102: Missing docstring in public method
COT/info.py:53 in public method package_list:
D102: Missing docstring in public method
COT/info.py:66 in public method verbosity:
D102: Missing docstring in public method
COT/inject_config.py:62 in public method config_file:
D102: Missing docstring in public method
COT/inject_config.py:84 in public method secondary_config_file:
D102: Missing docstring in public method
COT/ovf.py:371 in public method output_file:
D102: Missing docstring in public method
COT/ovf.py:491 in public method system_types:
D102: Missing docstring in public method
COT/ovf.py:514 in public method version_short:
D102: Missing docstring in public method
COT/submodule.py:131 in public method package:
D102: Missing docstring in public method
COT/submodule.py:184 in public method package:
D102: Missing docstring in public method
COT/submodule.py:206 in public method output:
D102: Missing docstring in public method
COT/vm_description.py:121 in public method output_file:
D102: Missing docstring in public method
COT/vm_description.py:180 in public method system_types:
D102: Missing docstring in public method
COT/vm_description.py:189 in public method version_short:
D102: Missing docstring in public method
COT/vm_description.py:198 in public method version_long:
D102: Missing docstring in public method
COT/helpers/helper.py:220 in public method name:
D102: Missing docstring in public method


Reply to this email directly or view it on GitHub
#107 (comment).

@@ -94,7 +94,8 @@ def __repr__(self):

class Definition(Value):

_fields = 'name _source start end docstring children parent'.split()
_fields = ['name', '_source', 'start', 'end', 'decorators', 'docstring',
'children', 'parent']
Copy link
Member

@Nurdok Nurdok Mar 22, 2015

Choose a reason for hiding this comment

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

Make this a tuple instead (it shouldn't be mutable).

@Nurdok
Copy link
Member

@Nurdok Nurdok commented Mar 22, 2015

I added my code review as comments.
Other than that, please also add your change to the release notes in the docs, under the development version.

Thanks!

@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Mar 22, 2015

Thanks for the thorough review! I'll address the comments and provide an updated changeset.

@@ -116,7 +117,8 @@ def __str__(self):

class Module(Definition):

_fields = 'name _source start end docstring children parent _all'.split()
_fields = ['name', '_source', 'start', 'end', 'decorators', 'docstring',
'children', 'parent', '_all']
Copy link
Member

@Nurdok Nurdok Mar 24, 2015

Choose a reason for hiding this comment

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

This should be a tuple too.

@Nurdok
Copy link
Member

@Nurdok Nurdok commented Mar 24, 2015

@glennmatthews just one more tiny fix and I'll merge this :)

@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Mar 25, 2015

Done. Thanks again! (And thanks to @adiroiban for the initial version of this enhancement)

Nurdok added a commit that referenced this issue Mar 25, 2015
Make setters private (rework of #69)
@Nurdok Nurdok merged commit 2b02b18 into PyCQA:master Mar 25, 2015
1 check passed
@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Jun 30, 2015

@Nurdok Can I expect a new release any time soon? I would like to enable pep257 on my project. 😄

@Nurdok
Copy link
Member

@Nurdok Nurdok commented Jun 30, 2015

@glennmatthews I'm currently working on a #96 and a version will be released once I'm done. It might take 2-3 weeks, though.

@glennmatthews
Copy link
Contributor Author

@glennmatthews glennmatthews commented Jun 30, 2015

Good enough for me. :-) Thanks for the reply!

Glenn

@glennmatthews glennmatthews mentioned this pull request Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants