| Conditions | 9 |
| Total Lines | 60 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | # pylint: disable=unused-variable,expression-not-assigned |
||
| 12 | def describe_model_mixin(): |
||
| 13 | |||
| 14 | @pytest.fixture |
||
| 15 | def mixed_class(): |
||
| 16 | |||
| 17 | @yorm.sync("tmp/model.yml") |
||
| 18 | class MyClass(ModelMixin): |
||
| 19 | pass |
||
| 20 | |||
| 21 | return MyClass |
||
| 22 | |||
| 23 | @pytest.fixture |
||
| 24 | def mixed_instance(mixed_class): |
||
| 25 | return mixed_class() |
||
| 26 | |||
| 27 | @patch('yorm.mixins.utilities') |
||
| 28 | def it_adds_a_new_method(utilities, mixed_class): |
||
| 29 | mixed_class.new('foobar', overwrite=True) |
||
| 30 | |||
| 31 | expect(utilities.mock_calls) == [ |
||
| 32 | call.create(mixed_class, 'foobar', overwrite=True) |
||
| 33 | ] |
||
| 34 | |||
| 35 | @patch('yorm.mixins.utilities') |
||
| 36 | def it_adds_a_find_method(utilities, mixed_class): |
||
| 37 | mixed_class.find('foobar', create=True) |
||
| 38 | |||
| 39 | expect(utilities.mock_calls) == [ |
||
| 40 | call.find(mixed_class, 'foobar', create=True) |
||
| 41 | ] |
||
| 42 | |||
| 43 | @patch('yorm.mixins.utilities') |
||
| 44 | def it_adds_a_match_method(utilities, mixed_class): |
||
| 45 | mixed_class.match(foo='bar') |
||
| 46 | |||
| 47 | expect(utilities.mock_calls) == [ |
||
| 48 | call.match(mixed_class, foo='bar') |
||
| 49 | ] |
||
| 50 | |||
| 51 | @patch('yorm.mixins.utilities') |
||
| 52 | def it_adds_a_load_method(utilities, mixed_instance): |
||
| 53 | mixed_instance.load() |
||
| 54 | |||
| 55 | expect(utilities.mock_calls) == [ |
||
| 56 | call.load(mixed_instance) |
||
| 57 | ] |
||
| 58 | |||
| 59 | @patch('yorm.mixins.utilities') |
||
| 60 | def it_adds_a_save_method(utilities, mixed_instance): |
||
| 61 | mixed_instance.save() |
||
| 62 | |||
| 63 | expect(utilities.mock_calls) == [ |
||
| 64 | call.save(mixed_instance) |
||
| 65 | ] |
||
| 66 | |||
| 67 | @patch('yorm.mixins.utilities') |
||
| 68 | def it_adds_a_delete_method(utilities, mixed_instance): |
||
| 69 | mixed_instance.delete() |
||
| 70 | |||
| 71 | expect(utilities.mock_calls) == [ |
||
| 72 | call.delete(mixed_instance) |
||
| 74 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.