This repository was archived by the owner on Feb 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Update python files with some moderately aggressive linting. #54
Open
wtokumaru
wants to merge
4
commits into
chronoscio:master
Choose a base branch
from
wtokumaru:lint
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Generated by Django 2.1.2 on 2018-10-14 00:09 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('api', '0004_auto_20181011_0231'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='entity', | ||
| name='name', | ||
| field=models.TextField(help_text='Canonical name, which should not include any epithets and must be unique', max_length=100, unique=True), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='historicalentity', | ||
| name='name', | ||
| field=models.TextField(db_index=True, help_text='Canonical name, which should not include any epithets and must be unique', max_length=100), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='historicalpoliticalentity', | ||
| name='name', | ||
| field=models.TextField(db_index=True, help_text='Canonical name, which should not include any epithets and must be unique', max_length=100), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,24 +11,24 @@ | |
|
|
||
|
|
||
| class EntityManager(PolymorphicManager): | ||
| """ | ||
| Manager for the Nation model to handle lookups by url_id | ||
| """ | ||
| """Manager for the Nation model to handle lookups by url_id.""" | ||
|
|
||
| def get_by_natural_key(self, url_id): | ||
| def get_by_natural_key(self, url_id): # noqa | ||
| return self.get(url_id=url_id) | ||
|
|
||
|
|
||
| class Entity(PolymorphicModel): | ||
| """ | ||
| Cultural/governmental entity. Serves as foreign key for most Territories | ||
| """Cultural/governmental entity. | ||
|
|
||
| Serves as foreign key for most Territories. | ||
| """ | ||
|
|
||
| objects = EntityManager() | ||
|
|
||
| name = models.TextField( | ||
| max_length=100, | ||
| help_text="Canonical name, should not include any epithets, must be unique", | ||
| help_text="Canonical name, which should not include any epithets and" | ||
| " must be unique", | ||
| unique=True, | ||
| ) | ||
| url_id = models.SlugField( | ||
|
|
@@ -52,15 +52,17 @@ class Entity(PolymorphicModel): | |
| ) | ||
|
|
||
| def natural_key(self): | ||
| """Return the ID for lookups.""" | ||
| return self.url_id | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
|
|
||
|
|
||
| class PoliticalEntity(Entity): | ||
| """ | ||
| Cultural/governmental entity. Serves as foreign key for most Territories | ||
| """Cultural/governmental entity. | ||
|
|
||
| Serves as foreign key for most Territories. | ||
| """ | ||
|
|
||
| color = ColorField( | ||
|
|
@@ -79,16 +81,15 @@ class PoliticalEntity(Entity): | |
|
|
||
| # History fields | ||
|
|
||
| # Foreign key to auth.User which will be updated every time the model is changed, | ||
| # and is this stored in history as the user to update a specific revision | ||
| # Consider other metadata (DateTime) for the revision (may be handled by django-simple-history) | ||
| # Foreign key to auth.User which we update every time the model changes, | ||
| # and store in history as the user to update a specific revision. | ||
| # Consider other metadata (DateTime) for the revision | ||
| # (may be handled by django-simple-history). | ||
| # TODO: implement this | ||
|
|
||
|
|
||
| class Territory(models.Model): | ||
| """ | ||
| Defines the borders and controlled territories associated with an Entity. | ||
| """ | ||
| """Defines the borders and territories associated with an Entity.""" | ||
|
|
||
| class Meta: | ||
| verbose_name_plural = "territories" | ||
|
|
@@ -103,16 +104,17 @@ class Meta: | |
| history = HistoricalRecords() | ||
|
|
||
| def clean(self, *args, **kwargs): | ||
| """Ensure that our geometry is a polygon and our dates do not intersect | ||
| with those of another Territory of the same Entity.""" | ||
| if self.start_date > self.end_date: | ||
| raise ValidationError("Start date cannot be later than end date") | ||
| if ( | ||
| loads(self.geo.json)["type"] != "Polygon" | ||
| and loads(self.geo.json)["type"] != "MultiPolygon" | ||
| loads(self.geo.json)["type"] != "Polygon" and | ||
| loads(self.geo.json)["type"] != "MultiPolygon" | ||
| ): | ||
| raise ValidationError( | ||
| "Only Polygon and MultiPolygon objects are acceptable geometry types." | ||
| ) | ||
|
|
||
| "Only Polygon and MultiPolygon objects are acceptable geometry" | ||
| " types.") | ||
| try: | ||
| # This date check is inculsive. | ||
| if Territory.objects.filter( | ||
|
|
@@ -121,14 +123,15 @@ def clean(self, *args, **kwargs): | |
| entity__exact=self.entity, | ||
| ).exists(): | ||
| raise ValidationError( | ||
| "Another territory of this PoliticalEntity exists during this timeframe." | ||
| "Another territory of this PoliticalEntity exists during" | ||
| " this timeframe." | ||
| ) | ||
| except Entity.DoesNotExist: | ||
| pass | ||
|
|
||
| super(Territory, self).clean(*args, **kwargs) | ||
|
|
||
| def save(self, *args, **kwargs): | ||
| def save(self, *args, **kwargs): # noqa | ||
| self.full_clean() | ||
| super(Territory, self).save(*args, **kwargs) | ||
|
|
||
|
|
@@ -141,10 +144,7 @@ def __str__(self): | |
|
|
||
|
|
||
| class DiplomaticRelation(models.Model): | ||
| """ | ||
| Defines political and diplomatic interactions between PoliticalEntitys. | ||
| """ | ||
|
|
||
| """Defines interactions between PoliticalEntitys.""" | ||
| start_date = models.DateField(help_text="When this relation takes effect") | ||
| end_date = models.DateField(help_text="When this relation ceases to exist") | ||
| parent_parties = models.ManyToManyField( | ||
|
|
@@ -172,13 +172,13 @@ class DiplomaticRelation(models.Model): | |
|
|
||
| history = HistoricalRecords() | ||
|
|
||
| def clean(self, *args, **kwargs): | ||
| def clean(self, *args, **kwargs): # noqa | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Disable the rule thats necessitating these noqa? |
||
| if self.start_date > self.end_date: | ||
| raise ValidationError("Start date cannot be later than end date") | ||
|
|
||
| super(DiplomaticRelation, self).clean(*args, **kwargs) | ||
|
|
||
| def save(self, *args, **kwargs): | ||
| def save(self, *args, **kwargs): # noqa | ||
| self.full_clean() | ||
| super(DiplomaticRelation, self).save(*args, **kwargs) | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.