Skip to content

Commit

Permalink
Improve docstrings (#67)
Browse files Browse the repository at this point in the history
* Improve docstrings

* Update tests' python version

* Update python version syntax
  • Loading branch information
willemarcel committed Aug 27, 2024
1 parent 804cdcb commit a10d272
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: [3.9, "3.10"]

steps:
- uses: actions/checkout@v2
Expand Down
19 changes: 10 additions & 9 deletions osmcha/changeset.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class InvalidChangesetError(Exception):


def get_user_details(user_id):
"""Get information about number of changesets, blocks and mapping days of a
user, using both the OSM API and the Mapbox comments APIself.
"""Get information about the number of changesets, blocks and mapping days
of a user, using the OSM API.
"""
reasons = []
try:
Expand Down Expand Up @@ -240,7 +240,7 @@ def get_area(self, geojson):
)

def filter(self):
"""Filter the changesets that intersects with the geojson geometry."""
"""Filter the changesets that intersect with the geojson geometry."""
self.content = [
ch
for ch in self.xml
Expand All @@ -249,15 +249,15 @@ def filter(self):


class Analyse(object):
"""Analyse a changeset and define if it is suspect."""
"""Analyse a changeset and evaluate if it is suspect."""

def __init__(self, changeset, create_threshold=200, modify_threshold=200,
delete_threshold=30, percentage=0.7, top_threshold=1000,
suspect_words=WORDS['common'] + WORDS['sources'],
illegal_sources=WORDS['sources'], excluded_words=WORDS['exclude']):
if type(changeset) in [int, str]:
self.set_fields(changeset_info(get_metadata(changeset)))
elif type(changeset) == dict:
elif type(changeset) is dict:
self.set_fields(changeset)
else:
raise InvalidChangesetError(
Expand All @@ -275,7 +275,7 @@ def __init__(self, changeset, create_threshold=200, modify_threshold=200,
self.suspect_words = suspect_words

def set_fields(self, changeset):
"""Set the fields of this class with the metadata of the analysed
"""Set the class attributes with the metadata of the analysed
changeset.
"""
self.id = int(changeset.get('id'))
Expand Down Expand Up @@ -321,7 +321,7 @@ def label_suspicious(self, reason):
self.is_suspect = True

def full_analysis(self):
"""Execute the count and verify_words methods."""
"""Execute the count and verify methods."""
self.count()
self.verify_words()
self.verify_user()
Expand All @@ -337,8 +337,9 @@ def verify_warning_tags(self):
self.label_suspicious(item)

def verify_user(self):
"""Verify if the changeset was made by a inexperienced mapper (anyone
with less than 5 edits) or by a user that was blocked more than once.
"""Verify if the changeset was created by a inexperienced mapper
(anyone with less than 5 edits) or by a user that was blocked more
than once.
"""
user_reasons = get_user_details(self.uid)
[self.label_suspicious(reason) for reason in user_reasons]
Expand Down

0 comments on commit a10d272

Please sign in to comment.