democritus-project / d8s-python

Democritus functions for working with Python ASTs.
GNU Lesser General Public License v3.0
2 stars 4 forks source link

Write function to find number of lines in python code #7

Closed fhightower closed 3 years ago

fhightower commented 3 years ago

HELP WANTED 👋 : If you'd like to take this challenge on, please let me know! Even if you're new to Python and/or Github, this is a great place to start and I'd be happy to help walk you through this challenge as much as you need - don't hesitate to ask.

This particular issue will give you some exposure to writing a simple function and writing tests for that function.


What?

I would like a function to find the number of lines in Python code.

I envision the signature of such a function looking like:

def python_line_count(python_code: str, *, ignore_empty_lines: bool = True) -> int:

Why?

Counting lines of code is a common use-case.

How?

This function can be modeled on the python_function_line_count function.

kshru9 commented 3 years ago

Hey, I would like to take this up. I am a complete newbie on making contributions on github. And so I would need some help to accomplish the challenge. I hope you don't mind that.

Can you please tell that in which files I have to make changes. Is it the modeled function ?

fhightower commented 3 years ago

Wonderful 🎉 ! Thanks for wanting to be involved and I don't mind helping at all @ShrutiKatpara!

Here is the process we'll follow:

  1. Claim the task/issue you want to work on
    • This is already done! I've assigned this issue to you and we'll close it when you're done.
  2. Fork this repository
  3. Clone the forked repository locally
  4. Create a branch
    • I recommend starting your branch name with the issue number you are working on (in this case, issue #7)
    • I also recommend giving your branch a helpful name
    • Combining these ^ two points of advice, I'd suggest naming your branch something like 7-add-line-count-func
  5. Make your code changes
    • This is where you actually modify and improve the code
  6. Write tests
    • All new functions should have some tests written for them
  7. Push your changes to your fork
  8. Create a pull request from your fork to this repository
  9. We'll review the updates you made and merge the PR!

Questions? Please Ask!

If you have any follow-up questions, don't hesitate to ask! It takes practice to understand how to contribute to software, so there is no shame in asking for help.

kshru9 commented 3 years ago

Thanks @fhightower for all the guidance.

I will start working on the issue.

kshru9 commented 3 years ago

Hey @fhightower. Just to be clear. I saw that the python_function_line_count is already implemented in the package.

Is my task to test the function by generating test files and correct the function wherever it fails?

fhightower commented 3 years ago

Thanks for asking @ShrutiKatpara and I have to apologize; my original comment was not very clear and was misleading.

I think the best approach is to rename the python_function_line_count to make it more general. Currently, the name of the function makes it sound like it only counts lines for functions, but this is not the case; it can count lines for any given string of code. So, your task is to update the name of the function python_function_line_count to python_line_count (or something like that) and then update:

Does that make sense? Thanks again for clarifying this.

kshru9 commented 3 years ago

Yeah sure. Thanks @fhightower . I think I misunderstood the task. Thanks for clarifying me.

riyalalwani19 commented 3 years ago

I would also like to work on this. Is it possible to assign it to two people?

fhightower commented 3 years ago

Thanks for reaching out @riyalalwani19 👋 !

Yes, we can assign two people to this issue, but that is up to @ShrutiKatpara . @ShrutiKatpara: would you like some help from @riyalalwani19 on this issue or do you prefer to work on it alone? Either way is fine.

In the mean time, @riyalalwani19, there are some other issues in the Democritus Project for which we are looking for help:

Please let me know if any one of these (or any other issue) looks interesting.

kshru9 commented 3 years ago

I have no issues to collaborate with @riyalalwani19 . I would be happy instead. Thanks.

fhightower commented 3 years ago

Sweet, I've added @riyalalwani19 as an assignee for this issue (thanks @riyalalwani19 for being willing to help 🎉 ).

Also, I've merged a PR that updated this repo so you may want to pull the changes if you have this repo cloned locally.