Skip to content

Fixing: flake8 E402 and windows setup.py not working #955

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys
import os

import dateparser

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
Expand All @@ -23,8 +24,6 @@
# version is used.
sys.path.insert(0, project_root)

import dateparser

Copy link
Collaborator

@noviluni noviluni Aug 7, 2021

Choose a reason for hiding this comment

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

From what I read in the comments:

Insert the project root dir as the first element in the PYTHONPATH.
This lets us ensure that the source package is imported, and that its
version is used.

I think that this import is here intentionally. I'm not sure if moving it from here would have any adversarial consequence. Wouldn't be better to change it to...

import dateparser  # noqa: E402

just in case? @Gallaecio

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, I've seen that in parsel has the import above, so maybe I'm worrying unnecessarily:

https://github.com/scrapy/parsel/blob/master/docs/conf.py

Copy link
Member

Choose a reason for hiding this comment

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

I had not thought of that. Indeed, having it after will prevent a system-wide-installed version of dateparser being used instead.

It should not be a problem when using tox though, I believe, since tox installs the project into its virtual environment every time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer to keep it where it was to avoid needing to modify the comments, etc.

@gavishpoddar could you move it again where it was and add the "noqa"?:

import dateparser # noqa: E402

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍🏻

# -- General configuration ---------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

__version__ = re.search(r"__version__.*\s*=\s*[']([^']+)[']", open('dateparser/__init__.py').read()).group(1)

introduction = re.sub(r':members:.+|..\sautomodule::.+|:class:|:func:|:ref:', '', open('docs/introduction.rst').read())
history = re.sub(r':mod:|:class:|:func:', '', open('HISTORY.rst').read())
introduction = re.sub(r':members:.+|..\sautomodule::.+|:class:|:func:|:ref:', '', open('docs/introduction.rst', encoding="utf8").read())
history = re.sub(r':mod:|:class:|:func:', '', open('HISTORY.rst', encoding="utf8").read())

test_requirements = open('tests/requirements.txt').read().splitlines()

Expand Down