Skip to content
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

Use built-in open whenever possible #208

Merged
merged 8 commits into from Aug 13, 2018
Merged

Use built-in open whenever possible #208

merged 8 commits into from Aug 13, 2018

Conversation

mpenkov
Copy link
Collaborator

@mpenkov mpenkov commented Jul 7, 2018

Resolve issue #207

import sys

try:
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

I think better to add numpy to test dependencies https://github.com/RaRe-Technologies/smart_open/blob/master/setup.py#L19

Copy link
Contributor

Choose a reason for hiding this comment

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

Or even add it like standart unittest (not integration), wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TBH, I don't think numpy belongs in our dependencies, because we only need it for one thing: to run this test.

What else would be the benefit of including it?

Copy link
Contributor

Choose a reason for hiding this comment

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

because we only need it for one thing: to run this test.

yes, and I'm talking about test dependencies (not requirements of smart_open package)

What else would be the benefit of including it?

No, only for correct run test, that's all

dt = np.dtype([('time', [('min', int), ('sec', int)]), ('temp', float)])
x = np.zeros((1,), dtype=dt)

fname = "test.dat"
Copy link
Contributor

Choose a reason for hiding this comment

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

better to use really tempfiles, instead of hardcoded names

@@ -0,0 +1,28 @@
import os
Copy link
Contributor

Choose a reason for hiding this comment

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

can you run this file in CI too (and other integration tests that missed) please?

Copy link
Collaborator Author

@mpenkov mpenkov Jul 27, 2018

Choose a reason for hiding this comment

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

I added this test. There are no other tests that we can run automatically right now - the remaining tests require user input. They'll need a bit of work before they can be fully automatic.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aha, ok, we can do it later (out of scope of current PR)

@@ -284,6 +284,16 @@ def _shortcut_open(uri, mode, **kw):
open_kwargs['encoding'] = encoding
mode = mode.replace('b', '')

#
# Under Py3, the built-in open accepts kwargs, and it's OK to use that.
# Under Py2, the built-in open _doesn't_ accept kwargs, but we still use it
Copy link
Contributor

Choose a reason for hiding this comment

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

@piskvorky
Copy link
Owner

piskvorky commented Jul 19, 2018

@mpenkov please use descriptive issue/PR titles & put fixes #XYZ only in the description. It makes for easier issue/PR scanning, and also allows Github to hyperlink the pages. Thanks.

@mpenkov mpenkov changed the title Resolve issue #207 Use built-in open whenever possible Jul 27, 2018
- use tempfile instead of hard-coded file
- integrate new test into travis.yml so that Travis runs it
@mpenkov
Copy link
Collaborator Author

mpenkov commented Jul 27, 2018

@menshikh-iv I've responded to your comments. Please have a look.

@menshikh-iv
Copy link
Contributor

@mpenkov done

@piskvorky
Copy link
Owner

piskvorky commented Aug 10, 2018

LGTM.

@menshikh-iv @mpenkov How about another release? This PR will be a welcome, important change.

Btw, smart_open just reached 1,000 starts on Github 🌟 Thanks a lot @mpenkov for your continued support, it's really great!

@mpenkov
Copy link
Collaborator Author

mpenkov commented Aug 12, 2018

@piskvorky Thank you!!

@menshikh-iv Is there anything left to do for this? If not, let's merge.

@menshikh-iv
Copy link
Contributor

@mpenkov LGTM for me too, thank you!
@piskvorky almost nothing to release IMO, I would like to do this later (after several more PRs will be merged).

@menshikh-iv menshikh-iv merged commit 1c43f19 into master Aug 13, 2018
@menshikh-iv menshikh-iv deleted the 207 branch August 13, 2018 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants