0

My code is failing (or at least not parsing properly) when I run check50.

:| quote handles valid ticker symbol
check50 ran into an error while running checks!
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  File "/usr/local/lib/python3.7/site-packages/check50/runner.py", line 142, in wrapper
state = check(*args)
  File "/home/ubuntu/.local/share/check50/cs50/problems/finance/__init__.py", line 108, in quote_handles_valid
.content(r"28\.00", "28.00", name="body"))
  File "/usr/local/lib/python3.7/site-packages/check50/flask.py", line 135, in content
lambda regex, content: any(regex.search(str(tag)) for tag in content.find_all(**kwargs)))
  File "/usr/local/lib/python3.7/site-packages/check50/flask.py", line 159, in _search_page
if not match_fn(regex, content):
  File "/usr/local/lib/python3.7/site-packages/check50/flask.py", line 135, in <lambda>
lambda regex, content: any(regex.search(str(tag)) for tag in content.find_all(**kwargs)))
  File "/usr/local/lib/python3.7/site-packages/check50/flask.py", line 135, in <genexpr>
lambda regex, content: any(regex.search(str(tag)) for tag in content.find_all(**kwargs)))
  File "/usr/local/lib/python3.7/site-packages/bs4/element.py", line 1075, in __unicode__
return self.decode()
  File "/usr/local/lib/python3.7/site-packages/bs4/element.py", line 1111, in decode
formatter = self.formatter_for_name(formatter)
  File "/usr/local/lib/python3.7/site-packages/bs4/element.py", line 167, in formatter_for_name
if isinstance(formatter, collections.Callable):
  File "/usr/local/lib/python3.7/collections/__init__.py", line 52, in __getattr__
DeprecationWarning, stacklevel=2)
sending POST request to /login
sending POST request to /quote
checking that status code 200 is returned...
checking that "28.00" is in page

I am not sure it is my code that is causing the problem, I am guessing it is an issue with the code check50 is running and it not being compitable with the version of python in the IDE.

Just in case I am wrong here is the code for quote (I get the same for buy)

@app.route("/quote", methods=["GET", "POST"])
@login_required
def quote():
 """Get stock quote."""
 if request.method =="POST":
     if not request.form.get("symbol"):
         return apology("Enter a symbol")
     else:
         symbol = request.form.get("symbol")
         response = lookup(symbol)
         if not response:
             return apology("Unable to locate stock")
         else:
             response["price"] = usd(response["price"])
             return render_template("quoted.html", stock=response)
 else:
     return render_template("quote.html")

Any help or thoughts gratefully received.

1

You can disable the deprecation warning by following the instructions at:

https://stackoverflow.com/questions/14463277/how-to-disable-python-warnings

Specifically, using the first code block in the answer with ~436 upvotes, which discusses the python docs. I had the same problem around the same time and was able to check50 in the normal way afterwards.

Please mark this as giving the right answer if itsolves the problem for you!

  • Thanks Charlie, that did the trick. Only one error message left but I think that one is down to me! – Simon Rowe Oct 20 '19 at 15:33
  • for anyone else coming to this cold add import warnings to the top of applications.py and then warnings.filterwarnings("ignore", category=DeprecationWarning) to the main body of the file. – Simon Rowe Oct 20 '19 at 15:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .