Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Refactor - split to modules, add parser tests, update readme #200

Merged
merged 21 commits into from
Sep 11, 2016

Conversation

Nurdok
Copy link
Member

@Nurdok Nurdok commented Aug 2, 2016

@sigmavirus24 If you have some time, I'd love it if you could give this a look.
Also, this fixes #196.

tox
pathlib
Copy link
Member

Choose a reason for hiding this comment

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

So, I have a quibble with this file. Is tox a test dependency and the rest are dependencies enumerated in tox, or are these test dependencies and tox is a different kind of requirement?

Copy link
Member Author

Choose a reason for hiding this comment

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

Separated to tests.txt and test_env.txt.

# Conflicts:
#	src/pydocstyle.py
#	src/pydocstyle/tests/test_decorators.py
@Nurdok
Copy link
Member Author

Nurdok commented Sep 6, 2016

@sigmavirus24 care to take another look? I fixed the issue with the main module and also had to do a manual merge from #203 .


Example
-------
>>> check(['pydocstyle.py'], checked_codes=['D100'])
Copy link
Member

Choose a reason for hiding this comment

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

FYI, checked_codes will no longer work

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the docstring.

count = 0
for error in errors:
sys.stderr.write('%s\n' % error)
code = ReturnCode.violations_found
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to reassign this for every error? Why not do something like:

count = 0
for error in errors:
    print('%s' % error)   # because we all agree sys.stderr isn't correct
    count += 1
if count > 0:
   code = ReturnCode.violations_found
else:
   code = ReturnCode.no_violations_found

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@sigmavirus24
Copy link
Member

Sorry for the lag in review @Nurdok this is a huge change, and my own personal life is a bit hectic and will be so for a couple weeks. So I'm reviewing this in chunks of free time as I find them. =)


count = 0
for error in errors:
sys.stderr.write('%s\n' % error)
Copy link
Member

Choose a reason for hiding this comment

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

print instead of sys.stderr?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this is a change in behavior, I'd rather do this in a separate PR from this refactoring.

Copy link
Member

Choose a reason for hiding this comment

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

That sounds perfectly reasonable to me :)

@sigmavirus24
Copy link
Member

Some questions too:

  • I see you have moved the tests into src/pycodestyle. Do you then plan to ship those tests so people can run them on their system after install? Is this for convenience? If so, what convenience?
  • You have pycodestyle/main.py that reminds me that people can (probably, I haven't tested this) currently do python -m pycodestyle [options] file.py to invoke pycodestyle. As you have this structured now, they cannot do that. Do you wish to continue supporting that? (To do so, you need a pycodestyle/__main__.py that does pretty much exactly the same thing as pycodestyle/main.py.

@Nurdok
Copy link
Member Author

Nurdok commented Sep 7, 2016

No problem about the lag - I appreciate the review and it's not urgent.

  • Regarding test location - I did this sort of on instinct. I guess putting the test next to pydocstyle would be more convenient. I'll go ahead and do that.
  • Regarding main - I actually didn't know about __main__.py. I'll read about it and change it to support python -m pydocstyle *.

Thanks!

@sigmavirus24
Copy link
Member

@Nurdok having the tests in the package is perfectly fine too. I didn't mean to convince you to undo that. I'm just curious as to why you did it.

The reason I ask is because I have seen the benefit of always importing the fully-qualified module after it's been installed in the virtualenv via tox. This is why Flake8 has src/flake8 and tests/ so that the tests are easily editable (because I'm super lazy) and it relies on flake8 being installed prior to running the tests. The layout is personal preference.

The reason I bring this up is because I think I saw relative imports in the tests and that concerns me a bit. If you're not testing what gets installed into a virtualenv, you're not testing what a user will receive after running pip install pydocstyle. Does that make sense?

@Nurdok
Copy link
Member Author

Nurdok commented Sep 7, 2016

I realize the test location is a preference, but as I read your suggestion it immediately became clear to me that it would solve all the ugly relative imports, so I'll take it :)

@sigmavirus24
Copy link
Member

Hah, cool. =D

@Nurdok
Copy link
Member Author

Nurdok commented Sep 7, 2016

Do you see a reason not to put tests in src? i.e., have pydocstyle and tests siblings in the src directory. It will still have the benefits you describe, since the tests directory will not be installed in the virtualenv.

@sigmavirus24
Copy link
Member

Nope. =)

@Nurdok
Copy link
Member Author

Nurdok commented Sep 8, 2016

I completed both points, although __main__ does not work for Python 2.6.

@Nurdok Nurdok merged commit d22428e into PyCQA:master Sep 11, 2016
@Nurdok
Copy link
Member Author

Nurdok commented Sep 11, 2016

@sigmavirus24 I merged this so that other work on pydocstyle can continue. If you have further comments, I'll be happy to hear them.

Cheers!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pydocstyle fails on "raise X from Y"
2 participants