Skip to content

Improved readability of web_programming/get_imdbtop.py and added documentations with doctests - #4855

Merged
cclauss merged 10 commits into
TheAlgorithms:masterfrom
appledora:crawl-imdb-topn-movies
Oct 16, 2021
Merged

Improved readability of web_programming/get_imdbtop.py and added documentations with doctests#4855
cclauss merged 10 commits into
TheAlgorithms:masterfrom
appledora:crawl-imdb-topn-movies

Conversation

@appledora

Copy link
Copy Markdown

Updated an existing script web_programming/get_imdbtop.py to crawl top n movies from the imdb databse based on ratings. It includes documentations and doctests. Modularized the script and made it more customizable. Fixed formatting using black and flake8.

  • [] Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • [] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@appledora
appledora requested a review from cclauss as a code owner October 1, 2021 17:59
@ghost ghost added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Oct 1, 2021
Comment thread web_programming/get_imdbtop.py Outdated
Comment thread web_programming/get_imdbtop.py Outdated
@appledora
appledora requested a review from cclauss October 2, 2021 06:43
Comment thread web_programming/get_imdbtop.py Outdated
"""
print(f"Crawling {num_movies} movies from the IMDB databse ...")

print(f"Crawling {num_movies} movies from the IMDB database...")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Move print() outside the algorithmic function.

Comment thread web_programming/get_imdbtop.py Outdated
@ghost ghost added the tests are failing Do not merge until tests pass label Oct 2, 2021
@appledora
appledora requested a review from cclauss October 2, 2021 14:19
@cclauss

cclauss commented Oct 2, 2021

Copy link
Copy Markdown
Member

mypy found problems on lines 26, 46, and 47

web_programming/get_imdbtop.py:26: error: Return value expected
web_programming/get_imdbtop.py:46: error: Incompatible types in assignment (expression has type "int", variable has type "str")
web_programming/get_imdbtop.py:47: error: Argument 1 to "crawl_imdb_topn_movies" has incompatible type "str"; expected "int"

@appledora

Copy link
Copy Markdown
Author

mypy found problems on lines 26, 46, and 47

web_programming/get_imdbtop.py:26: error: Return value expected
web_programming/get_imdbtop.py:46: error: Incompatible types in assignment (expression has type "int", variable has type "str")
web_programming/get_imdbtop.py:47: error: Argument 1 to "crawl_imdb_topn_movies" has incompatible type "str"; expected "int"

I think I have fixed this, by running mypy locally

@ghost ghost removed the tests are failing Do not merge until tests pass label Oct 3, 2021
@ghost ghost mentioned this pull request Oct 5, 2021
14 tasks
@appledora

Copy link
Copy Markdown
Author

@poyea Could you kindly review this one?

@ghost ghost added the tests are failing Do not merge until tests pass label Oct 16, 2021
@ghost ghost removed the tests are failing Do not merge until tests pass label Oct 16, 2021
@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Oct 16, 2021
@cclauss
cclauss merged commit 3738588 into TheAlgorithms:master Oct 16, 2021
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
…mentations with doctests (TheAlgorithms#4855)

* improved readability of the existing method by reformatting, adding documentations with doctests.

* improved readability of the existing method by reformatting, adding documentations with doctests.

* fixed typo in test

* added doctest to parse dictionary method

* added doctest to parse dictionary method

* Changed return type, removed print() from method and implemented doctests as suggested

* Fixed doctest error, removed print() from method, created new script as suggested

* Update get_imdbtop.py

* Fix typo discovered by codespell

* return ()

Co-authored-by: Christian Clauss <cclauss@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants